None of my relations are on autoload, for efficiency’s sake. I am loading relations in rounds, getting some in the first round (in the viewDidLoad) and moving on to round 2 of loading relations after the view has loaded. My code to retrieve the first set of relations is as follows:
Fault *fault = nil;
BackendlessDataQuery *query = [BackendlessDataQuery new];
query.whereClause = [NSString stringWithFormat:@"objectid = \'%@\'", userToDisplay.objectId];
query.queryOptions.related = [NSMutableArray arrayWithArray:@[@"relation1", @"relation2", @"relation3.relation1-of-relation3"]];
NSArray *userData = [[backendless.persistenceService of:BackendlessUser.class] find:query fault:&fault].data;
userToDisplay = [userData objectAtIndex:0];
This is working fine, and userToDisplay now references a BackendlessUser object with the specified relations.
The second round of loading is as follows:
[backendless.persistenceService
load:userToDisplay
relations:@[@"relation3.relation2-of-relation3", @"relation3.relation3-of-relation3", @"relation4.*"]
response:^(id response)
{
userEvents = [self getUserEventsWithUser: userToDisplay];
}
error:^(Fault *fault)
{
NSLog(@"Fault: %@", fault.description);
}];
This is where the problem starts. Now, userToDisplay is a reference to a BackendlessUser object with relation1, relation2, and relation3, but only the sub-relations relation3.relation2-of-relation3 and relation3.relation3-of-relation3.
relation3.relation1-of-relation3, which I retrieved in the first round of loading, is now empty. This is a problem because I do not want to have to load it again because I already did, but if I don’t, it is empty.
Is there any way to add on more sub-relations to a user without emptying the sub-relations that aren’t specified in the second load?
Thanks