Saved object does not load relations

When updating an object the returned/saved object does not load the relations

e.g.
Table vehicle has relations to tables vehicle_make and vehicle_model and set to autoload these relations

//Retrieving a vehicle
Backendless.Data.of(“vehicle”).findById(…).then(vehicle=> {
// returned vehicle has the make and model relations
})

//update a vehicle
Backendless.Data.of(“vehicle”).save(vehicleObject).then(updatedVehicle=> {
//updatedVehicle only has vehicle properties, make and models relations are not loaded
})

Is this expected behaviour?

Thank you,
Constantin

Hi Constantin,

This is the expected behavior (for now, it may change in the future). When an object is being saved or updated, it is stripped of all the relations, saved/updated and then returned back.

Regards,
Mark

Hello @Constantin_Craciunescu

As a workaround, I can advise you to assign all the properties of the update object to the object with relations

Backendless.Data.of(“vehicle”).save(vehicleObject).then(updatedVehicle=> {
    Object.assign(vehicleObject, updatedVehicle)

   /// and then use vehicleObject.yourRelations
})

Regards, Vlad

Thanks Vladimir, I will try this

Thanks Mark