Skip to content

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:

EventHandler<Map> eventHandler = Backendless.Data.of( "TABLE-NAME" ).rt();
eventHandler.addBulkDeleteListener( String whereClause, AsyncCallback<BulkEvent> callback );
EventHandler<T> eventHandler = Backendless.Data.of( T.class ).rt();
eventHandler.addBulkDeleteListener( String whereClause, AsyncCallback<BulkEvent> callback );

Unconditional bulk delete listener

A unconditional bulk delete listener receives events when a client uses the bulkDelete API with any whereClause statement:

EventHandler<Map> eventHandler = Backendless.Data.of( "TABLE-NAME" ).rt();
eventHandler.addBulkDeleteListener( AsyncCallback<BulkEvent> callback );
EventHandler<T> eventHandler = Backendless.Data.of( T.class ).rt();
eventHandler.addBulkDeleteListener( AsyncCallback<BulkEvent> callback );

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:

// for the class-based approach:
eventHandler.removeBulkDeleteListener( AsyncCallback<T> listenerObject );

// for the map-based approach:
eventHandler.removeBulkDeleteListener( AsyncCallback<Map> listenerObject );