Hello,
How can i delete an existing relation between two objects in a table? Here are the steps i have used to create the relation itself:
BackendlessUser user1 = Backendless.Data.of( BackendlessUser.class ).findFirst();
BackendlessUser user2 = Backendless.Data.of( BackendlessUser.class ).findLast();
ArrayList<BackendlessUser> friends = new ArrayList<BackendlessUser>();
friends.add( user2 );
user1.setProperty( “myfriends”, friends );
Backendless.Data.of( BackendlessUser.class ).save( user1 );
Also, i have a screenshot of my table in attachments.
Thank you,
–Armen
Deleting a relationship is the reverse of adding one (obviously, right?
)
That is true for the code as well. If you need to delete a relationship, you would do the following:
Load an object with relations (there are different ways to do that: autoload or use "loadrelations" method)
Remove the related object from the collection (this is the reverse of step 4 in your post)
Save the parent object (which is the same as step 6 in your post)
Regards,
Mark