Hi,
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 :
http://image.prntscr.com/image/50fe8350cc774243b5c1f0290cd9ff7b.png</img>
http://image.prntscr.com/image/8bf9964bffeb4c4492146c57f1c340b4.png</img>
Here is the ERD
http://image.prntscr.com/image/c28c4aad37934addb306cfbef7c806a6.png</img>
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:
MyOils *newOil = [MyOils new];
newOil.MySingleOil = self.singleOil;
[allMyOils addObject:newOil];
[updatingUser setProperty:@"MyOils" object:allMyOils];
BackendlessUser *updatingUser = backendless.userService.currentUser;[backendless.userService update:updatingUser response:^(BackendlessUser *updatedUser) {
backendless.userService.currentUser = updatedUser;
} error:^(Fault *error) {}];
But in the Backendless 4 , I have make 4 server calls to get the same effect. With following code:
MyOils *newOil = [MyOils new];
id<IDataStore> dataStoreMyOils = [backendless.data 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 = [backendless.data 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?