Skip to content

Deleting Multiple Objects

This API deletes multiple objects in a data table with a single request. Consider the following example, it demonstrates an API call which deletes all objects in the Person data table where the value of the age property is greater than 20:

MapDrivenDataStore *dataStore = [Backendless.shared.data ofTable:@"Person"];
[dataStore removeBulkWithWhereClause:@"age > 20" responseHandler:^(NSNumber *removed) {
    NSLog(@"%@ objects have been removed", removed);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
let dataStore = Backendless.shared.data.ofTable("Person")
dataStore.removeBulk(whereClause: "age > 20", responseHandler: { removed in
    print("\(removed) objects have been removed")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

Available methods

- (void) removeBulkWithWhereClause:(NSString * _Nullable)whereClause responseHandler:^(NSNumber * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func removeBulk(whereClause: String?, responseHandler: ((NSNumber) -> Void)!, errorHandler: ((Fault) -> Void)!)

- (void) removeBulkWithWhereClause:(NSString * _Nullable)whereClause responseHandler:^(NSNumber * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func removeBulk(whereClause: String?, responseHandler: ((NSNumber) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument                Description
whereClause a condition for selecting objects in the data table which will be deleted.
responseHandler a block (closure) to handle successful result of an asynchronous call.
errorHandler a block (closure) to handle fault result of an asynchronous call.

Return Value

The API returns the number of objects deleted in the database as a result of the request.