Backendless Support
Waiting for user's response

Backendless 4 Issue with Data Relation Saving in iOS


I just created a new application using the backendless 4. But I am looking at the data relations in the tables for backendless 3 and 4 and it looks like there is too much overhead in the new system.

Here are the relation details :



Here is the ERD


The issue is in the old backendless 3, i just have to add create a new object for the MyOils class and add it in the property of Backendless user object then I just have to call 1 server call and it all gets saved to the server with proper relations. With following code:

  1. MyOils *newOil = [MyOils new];

    newOil.MySingleOil = self.singleOil;

  2. [allMyOils addObject:newOil];

    [updatingUser setProperty:@"MyOils" object:allMyOils];

  3. BackendlessUser *updatingUser = backendless.userService.currentUser;[backendless.userService update:updatingUser response:^(BackendlessUser *updatedUser) {
  4. backendless.userService.currentUser = updatedUser;
  5. } error:^(Fault *error) {}];

But in the Backendless 4 , I have make 4 server calls to get the same effect. With following code:

  1. MyOils *newOil = [MyOils new];

    id<IDataStore> dataStoreMyOils = [ of:[MyOils class]];

    [dataStoreMyOils save:newOil response:^(MyOils* newSavedOil) {

    [dataStoreMyOils setRelation:@"MySingleOil" parentObjectId:newSavedOil.objectId childObjects:@[self.singleOil.objectId] response:^(NSNumber *number) {

    id<IDataStore>dataStoreUsers = [ ofTable:@"Users"];

    [dataStoreUsers setRelation:@"MyOils" parentObjectId:backendless.userService.currentUser.objectId childObjects:@[newSavedOil.objectId] response:^(NSNumber *num) {

    [backendless.userService findById:backendless.userService.currentUser.objectId response:^(BackendlessUser *latestUser) {

    backendless.userService.currentUser = latestUser;

    } error:^(Fault *error) {}];} error:^(Fault *error) {}];} error:^(Fault *error) {}];} error:^(Fault *error) {}];

My Question is is this all correct?

Do I have to call the server 4 times now to get this working?

Or Am I missing a better way for that?

Leave a Comment

Comments (2)


Hi Umer

Thanks you for your question.

Yes, in 4.x you can not do that in a single request, you can add only exists(stored on the server) objects as relations to another exist object.

So, you can do 4 request:

1) create/save SingleOil

2) create/save MyOils

3) add saved SingleOil to saved MyOils

4) add saved MyOils to user

Or, I can propose you to use BusinessLogic for it, you can implement it via EventHandlers or APIServices

below you can see links for BL docs,

EventHandlers docs:

APIServices docs:

APIServices video:

Hope it will help you.

Regards, Vlad


Hi Vladimir U

Ok got your point.

Thanks for the quick reply.

Hopefully you guys will be working on this in the future as it seems to be real big overhead for now.