Backendless Support
 
Solved

Trouble adding to 1 to Many relation in the Users data table

There seem to be similar questions asked, but none of them have been sufficient in solving my problem. My problem is that updating a 1 to Many relation in the Users table SOMETIMES works. My code is as follows

  1. [user setProperty:@"conversations" object:@[conversation]];
  2. Fault *error = nil;
  3. [backendless.persistenceService save:user error:&error];

"conversations" is a 1 to Many data object relationship.

After executing this code, the conversations property has only 1 object, the conversation that it was just set to. The peculiar part of this code is that it works some of the time and for some users, but randomly. I executed this same piece of code for two different user objects, one after the other. For one of the users, the new conversation was added to the relation, resulting in 2 conversation objects in the "conversations" property. For the other, the first was overridden, resulting in only 1 conversation object in the "conversations" property. I am very confused as to why this is happening and I would appreciate some help.

In the question I have supplied all of the relevant code.

My APPID: C1C73839-75FD-DF58-FF72-2CBCEA0F9100

Leave a Comment

Comments (1)

photo
1

Hi,

To update User object you should retrieve this object from Backendless with relation you want to update( use relationDepth in find query, for example ). After that you can update/delete existing relations or add new.

Regards,

Denys