BlobCity DB

BlobCity DB

An open-source multi-model database, designed to meet a wide variety of data storage, fast data retrieval and analytics requirements.

Get Started    

Registering a Hook

A hook can be registered on a datastore or on a specific collection. A hook however at all times will operate on a collection. If only a datastore is specified for registering a hook, then the operation is equivalent to individually applying hooks on all collections within the datastore.

blobcity>hook add {ds/collection} {insert/update/delete} {event/
transaction} {url}
{
  "username": "root",
  "password": "root",
  "q": "hook-add",
  "ds": "ds",
  "c": "c",
  "p": {
    "type": "event/transaction",
    "operation": "insert/update/delete",
    "url": "https://<url>"
  }
}

{ds/collection} corresponds to an existent datastore or an existent collection within a datastore. If only a datastore is specified, the hook will be registered on all current and future collections present within the datastore. If a collection is specified, the hook is registered for only the specified collection.

{insert/update/delete} corresponds to the operation for which the hook is meant. insert corresponds to a record insert operation, update corresponds to a record update operation and delete corresponds to a record delete operation. Only one of these values can be specified in the command.

{event/transaction} corresponds to the type of hook. An event hook is a simple observer hook. An event hook is called in an asynchronous manner after the transaction is successfully committed. On the other hand, transaction hooks are called in a synchronous manner before the final commit phase of the on-going transaction. A transaction hook must respond back with a commit or rollback outcome, which will result in the on-going transaction to being correspondingly committed or rolled-back.

{url} corresponds to the URL on which the hook is hosted. The database will invoke a POST request on the URL passing JSON data corresponding to the hook.

A sample command to register an insert event hook on a Users collection within a Organisation datastore would look as shown below:

Registering a Hook


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.