losing relationship on user update

I have a one to one relationship from the “users” table to a table names “member”. When I update a user via Backendless.UserService.update(user) it is wiping out my member relationship. This worked in 3.0 but seems to behave differently in 4.0.

SocialTeeTimeV2
AppId: C25CB2C7-149D-F6DC-FF86-AEE62D080B00

Hi Dan,

Establishing and deleting relationships in Backendless 4 works differently than in 3.x. Please see the documentation for details:
https://backendless.com/docs/android/doc.html#related_objects

Regards,
Mark

Hi Mark,

I did see that. However, this was an established relationship from the 3.0 to 4.0 migration. Then once the relationship was lost i manually recreated the relationship which was also lost when updating the user.

Hi Mark,

Let’s ignore this issue for now…I’m sure it has to do with the new way we now have to create relationships (which btw I really like…make sense). I restructured my code to match the new way.

  1. I’m now getting a 500 error which states the error was sent to your team. Most recent error id: 70736CCC-9549-CA5A-FF51-CB75D8DC7200
  2. The new way of saving relationships requires that both the parent and child objects must be in backendless storage. If the parent object has the child relationship defined as required how can the parent object be in backendless storage with out the child relationship being set/added? I hope this makes sense.

Thanks,
Dan

Hi Mark,

So I’m still confused about Backendless.UserService.update(user). I’m trying through code to update the email address. When calling the update method it wipes out an existing relationship.

Dan

To clarify, I load the user using Backendless.UserService.getCurrentUser() which I’m assuming loads the relationship in question. I then update the email address and call Backendless.UserService.update(user). This works successfully but in the database my relationship is gone.

THanks,
Dan

Hi Dan,

  1. How can we reproduce the 500 error? Please describe steps to reproduce.

  2. You’re correct, it would not be possible - we will be removing support for required for relations in the upcoming build.

Regards,
Mark

Is this in 4.0 or 3.x?

Are you using Android SDK? The reason I ask is the method in Android is "Backendless.UserService.CurrentUser() and not “getCurrentUser()”

version: 4

I’m using the javascript SDK.
I’ll remove the required constraints on my relationships.
Regarding on how to reproduce, do you want me to send my code? In the end I (this is a repeat from above) call Backendless.UserService.getCurrentUser, update only the email address, and then I call Backendless.UserService.update. I pass the entire user object in the “update” call. I guess I could just pass the objectId and email address…right?

Dan,

I will create a test user account with some relations in your app and try as you said:

    login user call getCurrentUser Update email save the user object
Does it sound like a valid use-case to reproduce the problem?

Regards,
Mark

Update: I just passed in the user table objectId and email address and everything worked as expected. In 3.0 i was able to pass in the entire object (including relationships) without a problem. So all is good on my end…not sure if you still consider that a defect though. I think I good my issues crossed with this error and the 500. Let me make sure my code looks ok and then I’ll get back to you. Stay tuned.

Check out my recent reply.

Hi Dan,

do you see lost relationship of user in Admin Console? Just to clarify if the relation was lost in DB or while passing updated user object to client.

Yes, after I call the update method with the entire user object I can see the lost relationship in the Admin Console. Does that help?

Dan,

Could you please clarify: are you saying you can see the relationship in the console, but it is not returned back to you in the response for the update api call?

Mark

Ha, it’s hard through text sometimes. So, after the update i can no longer see the relationship in the console nor does it come back in the response

Here’s a video where I update an object property with the Update call. Relationship I had prior to update stays with object in console:
https://monosnap.com/file/W5fcZT0ZQar64Te3uX5U7YmZwceOzc

Hi mark, i think you can close this out. thanks for your help.

Hi guys, I’m confusing with updating of user(( Relationship is losing(

I read your docs with relationships, but I still can’t understand.

Please look at the video: https://www.dropbox.com/s/n5dqjbgvtac7tbj/user_saving.mov?dl=0
You can download it for better quality.
Before update I has Contacts and devices and after they are missed.
If it’s default behaviour, what the sense to return an object with missed fields.