Backendless Support
 
Answered

How to delete child items which is unlinked?

It hard to describe but easy to understand by checking my attached photo.

I want to delete those unlinked items.

Please help~

Thanks

Leave a Comment

Comments (3)

photo
1

Hi Chechia,

I can suggest you the next steps to solve this issue. It'll be working fine if you have the one-to-one relation between your tables.

* collect all rows of table 'User_backendless' which do not have the relation to parent table (use the method 'find' with where clause 'backendless_project_save[user_back].objectId is null')

* loop the collection and remove each row (use method 'remove')

Regards Ilya

photo
1

It works fine! Thanks your answer! Very great!

The code is following like this:

new Thread(new Runnable() {

@Override

public void run() {

String whereClause = "backness_project_save[user_back].objectId is null";

BackendlessDataQuery dataQuery = new BackendlessDataQuery();

dataQuery.setWhereClause( whereClause ); BackendlessCollection collection = Backendless.Data.of( User_backendness.class ).find(dataQuery);

List<User_backendness> mUser_backendnesses=collection.getCurrentPage();

for(User_backendness mUser_backendness:mUser_backendnesses ){

Log.d("Null_objectId",mUser_backendness.getObjectId()+"");

}

}

}).start();

photo
1

Thanks for your feedback.

Regards Ilya