Bulk Delete Listener¶
Listeners for bulk deletion work identically to the ones for single deletion. The difference is in the method names to add and remove listener objects:
Conditional bulk delete listener¶
A conditional bulk delete listener receives an event when an API client uses the BulkDelete
API to delete multiple objects in a table with the same whereClause statement as specified by the RT client:
var eventHandler = Backendless.Data.Of( "TABLE-NAME" ).RT();
eventHandler.AddBulkDeleteListener( whereClause, ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsDeleted( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// the where clause for which the bulk event has been triggered
public String WhereClause { get; }
// number of deleted objects
public int Count { get; }
}
}
var eventHandler = Backendless.Data.Of<T>().RT();
eventHandler.AddBulkDeleteListener( whereClause, ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsDeleted( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// the where clause for which the bulk event has been triggered
public String WhereClause { get; }
// number of deleted objects
public int Count { get; }
}
}
Unconditional bulk delete listener¶
A unconditional bulk delete listener receives events when a client uses the bulkDelete
API with any whereClause
statement:
var eventHandler = Backendless.Data.Of( "TABLE-NAME" ).RT();
eventHandler.AddBulkDeleteListener( ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsDeleted( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// this value will be null for the unconditional bulk delete event listener
public String WhereClause { get; set; }
// number of deleted objects
public int Count { get; set; }
}
}
var eventHandler = Backendless.Data.Of<T>().RT();
eventHandler.AddBulkDeleteListener( ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsDeleted( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// this value will be null for the unconditional bulk update event listener
public String WhereClause { get; set; }
// number of deleted objects
public int Count { get; set; }
}
}
Both conditional and unconditional event listeners receive the following information in the callback object. The properties listed below are included into the BulkEvent
object delivered to the listener's callback.
WhereClause
- the where clause value used in the API call to identify the objects deleted from the database.Count
- the number of objects deleted from the database.
Removing listeners¶
The method removes all registered listeners for the BulkDelete
event:
eventHandler.RemoveBulkDeleteListeners();
The method below removes all listeners which process events for a specific where clause.
The value of the whereClause
argument must be the same as one in the AddBulkDeleteListener
method:
eventHandler.RemoveBulkDeleteListeners( string whereClause );
Removing a specific listener¶
This method removes a listener identified by the callback object:
eventHandler.RemoveBulkUpdateListener( MultipleObjectsDeleted callback );