bulk remove with iOS SDK

Hello,

Is there any sample code of how to bulk remove objects using a where clause?

This code is not correct right?


let dataStore = backendless.persistenceService.of(BLSyncQueue().ofClass())
        
        let query = BackendlessDataQuery()
        query.whereClause = "blDeviceID = '\(blDeviceID)'"
        
        dataStore.removeAll(query)

Hi Barry,

The implementation is very inefficient… It will call the find API using your query, get a collection of objects back and then run the remove API for each object individually.

However, the REST API for bulk remove does it in a single shot (search for “bulk delete” in the doc):
https://backendless.com/documentation/data/rest/data_deleting_data_objects.htm

Regards,
Mark

Hi Mark,

Any chance that this REST method also gets supported in the iOS SDK?

If not: what is the most effective way using only the iOS SDK?

Thanks!

Hi Barry,

removeAll method removes all objects returnd as BackendlessCollection for your query, so you can use this scenario.

Regards,
Slava

Hi Slava,

But is this method going to be optimized in the future?

Thanks.

Yes, we plan to optimize it asap, so you could use it as is

That is great news, thanks!