Skip to content

Database Event Handlers

Save New Object API

beforeCreate

*argument blocks: *

Request Item - object to be saved in the Backendless database.

afterCreate

return value block:

Response Item - object saved in the Backendless database.

Update Existing Object API

beforeUpdate

*argument blocks: *

Request Item - an existing object to be updated in the Backendless database.

afterUpdate

return value block:

Response Item - object updated in the Backendless database.

Delete Object API

beforeRemove

*argument blocks: *

Request ItemId - objectId of the object to be deleted in the database.

afterRemove

return value block:

Response Result - a timestamp when the object was deleted.

Find Object by ID

beforeFindById

*argument blocks: *

Request ItemId - objectId of the object to retrieve from the database

Request ItemRelations - a collection of related properties to initialize and return along with the parent object.

afterFindById

return value block:

Response Item - object retrieved from the database.

Find Objects with a Query

beforeFind

*argument blocks: *

Request Query - a query object with the data retrieval properties (whereclause, sorting options, paging options, relations, relations depth)

afterFind

return value block:

Response Result - a collection of objects matching the request query.

Find First Object in the Table

beforeFirst

*argument blocks: *

None

afterFirst

return value block:

Response Result - the first object in the table

Find Last Object in the Table

beforeLast

*argument blocks: *

None

afterLast

return value block:

Response Result - the last object in the table

Get Schema for a Table

beforeDescribe

*argument blocks: *

Request ItemName - name of the table to get the schema definition of.

afterDescribe

return value block:

Response ItemProperties - a collection of objects describing table's columns. For the details on the response see the Retrieving Schema Definition section in the REST API documentation.

Load Object's Relations API

beforeLoadRelations

*argument blocks: *

Request Item Id - objectId of the parent object.

Request Entity Name - name of the table where the parent object is stored.

Request Item Relation - name of the relation to retrieve.

afterLoadRelations

return value block:

Response Result - a collection of child objects for the identified parent object and the named relation column.

Update Multiple Objects API

beforeUpdateBulk

*argument blocks: *

Request WhereClause - the whereClause statement defining the condition for the objects which must be updated.

Request Changes - an object containing property values which will be applied to all objects matching the provided whereClause.

afterUpdateBulk

return value block:

Response Result - number of updated objects.

Remove Multiple Objects API

beforeRemoveBulk

*argument blocks: *

Request WhereClause - the whereClause statement defining the condition for the objects which must be deleted.

afterRemoveBulk

return value block:

Response Result - number of deleted objects.

Get the Number of Objects in a Table API

beforeCount

*argument blocks: *

Request Query - the whereClause statement defining the condition for the objects to be counted. If the condition is not specified, the API will count all objects in the table.

afterCount

return value block:

Response Result - object count

Get the Object Count for a Table/Query API

beforeCount

*argument blocks: *

Request Query - the whereClause statement defining the condition for the objects to be counted. If the condition is not specified, the API will count all objects in the table.

afterCount

return value block:

Response Result - object count

Add Related Child Objects to a Parent API

beforeAddRelation

*argument blocks: *

Request ParentObjectId - objectId of the parent object in the relation.

Request Column Name - specification of the relation column name. Includes name of the 'child' data table, column name and cardinality in the following format columnName:childTableName:cardinality. The cardinality parameter is expressed as 1 for a one-to-one relation or n for a one-to-many relation.

Request Children Array OR Where Clause - either a collection of child object IDs or a whereClause identifying the objects in the child table which should be added to the relation.

afterAddRelation

return value block:

Response Result - number of objects added to the relation

Set Related Objects for a Parent API

beforeSetRelation

*argument blocks: *

Request ParentObjectId - objectId of the parent object in the relation.

Request Column Name - specification of the relation column name. Includes name of the 'child' data table, column name and cardinality in the following format columnName:childTableName:cardinality. The cardinality parameter is expressed as 1 for a one-to-one relation or n for a one-to-many relation.

Request Children Array OR Where Clause - either a collection of child object IDs or a whereClause identifying the objects in the child table which should be set in the relation.

afterSetRelation

return value block:

Response Result - number of objects set for the relation

Delete Child Objects from a Relation

beforeSetRelation

*argument blocks: *

Request ParentObjectId - objectId of the parent object in the relation.

Request Column Name - name of the related column.

Request Children Array OR Where Clause - either a collection of child object IDs or a whereClause identifying the objects in the child table which should be deleted from the relation.

afterSetRelation

return value block:

Response Result - number of objects deleted from the relation