Backendless Support
 
Waiting for user's response

Must load relations column when remove delete one?

Before parse.com, when I remove one, just call getRelation().remove({ Object Instance }).

It doesn't needed load all relations data.

Backendless just guided using List<{Relate Object}>.remove({ Relate object instance }) and saving Object.

If I need delete someone, must loading relations for it like that?

is any other case have?

Leave a Comment

Comments (4)

photo
1

Example)

** this condition : not loaded relations data.

Place.class

  1. class Place {
  2. .....
  3. List<BackendlessUser> favorites = new ArrayList<BackendlessUser>();
  4. }

when User bookmarked :

  1. place.favorites.add(User.class);
  2. Backendless.Persistence.of(Place.class).save(place);

when user unbookmarked :

  1. place.favorites.remove(User); // it can be? not loaded relations(favorites) data yet.
  2. Backendless.Persistence.of(Place.class).save(place);

photo
1

Hi Clark,

In case you just want to delete relation (unlink objects), here is the code you should use (it's from the docs):

  1. Backendless.Data.of( "Person" ).deleteRelation( parentObject, "address", children,
  2. new AsyncCallback<Void>()
  3. {
  4. @Override
  5. public void handleResponse( Void response )
  6. {
  7. Log.i( "MYAPP", "relation has been deleted" );
  8. }
  9. @Override
  10. public void handleFault( BackendlessFault fault )
  11. {
  12. Log.e( "MYAPP", "server reported an error - " + fault.getMessage() );
  13. }
  14. } );

photo
1

How about 3.x?

photo
1

There's no such API for 3.x, in that version you'll have to load relations and save the parent object, as you described.

photo