Skip to content

Bulk Update Listener

Listeners for bulk update work very similarly to the ones for single oject update. The differences between single object and bulk update include the method names to add and remove listener objects as well as the object delivered to the listener.

Conditional bulk update listener

When an API client executes a bulkUpdate API request using the same whereClause value as the one specified in addBulkUpdateListener, the listener receives a real-time event.

const eventHandler = Backendless.Data.of( 'TABLE-NAME' ).rt();

const callback = ({ whereClause, count }) => console.log( whereClause, count )
const onError = ({ message, code }) => console.log( 'Error:', message, 'Error Code:', code )

eventHandler.addBulkUpdateListener( whereClause, callback, onError );
const eventHandler = Backendless.Data.of( TABLENAMECLASS ).rt();

const callback = ({ whereClause, count }) => console.log( whereClause, count )
const onError = ({ message, code }) => console.log( 'Error:', message, 'Error Code:', code )

eventHandler.addBulkUpdateListener( whereClause, callback, onError );

Unconditional bulk update listener

The registered listener will receive a real-time request for all bulkUpdate API requests.

const eventHandler = Backendless.Data.of( 'TABLE-NAME' ).rt();

const callback = ({ whereClause, count }) => console.log( whereClause, count )
const onError = ({ message, code }) => console.log( 'Error:', message, 'Error Code:', code )

eventHandler.addBulkUpdateListener( callback, onError );
const eventHandler = Backendless.Data.of( TABLENAMECLASS ).rt();

const callback = ({ whereClause, count }) => console.log( whereClause, count )
const onError = ({ message, code }) => console.log( 'Error:', message, 'Error Code:', code )

eventHandler.addBulkUpdateListener( callback, onError );

For both conditional and unconditional update listeners, the  object received in the callback contains the following properties:

  • whereClause - the where clause value used in the API call to identify the objects updated in the database.
  • count - the number of objects updated in the database.

Removing listeners

The method removes all registered listeners for the bulk update event:

eventHandler.removeBulkUpdateListeners();

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 addBulkUpdateListener method:

eventHandler.removeBulkUpdateListeners( whereClause );

Removing a specific listener

This method removes a listener identified by the callback object:

eventHandler.removeBulkUpdateListener( callbackObject );