Available hooks for Dobo's operations. You can use these hooks to customize the behavior of the model's CRUD operations.

For any of the hooks below, you can also use the modelName in camelCase format to create a model-specific hook. If you choose to use this format, you must omit the first parameter (model) so that the hook function handler syntax will become like this:

dobo.{modelName}:beforeCreateRecord (body, options)
dobo.{modelName}:afterCreateRecord (body, options)
dobo.{modelName}:beforeFindRecord (filter, options)
dobo.{modelName}:afterFindRecord (filter, result, options)
...

You can use both formats simultaneously if you want. In that case, they will be executed in this order:

dobo:beforeCreateRecord (model, body, options)
dobo.{modelName}:beforeCreateRecord (body, options)
...
dobo.{modelName}:afterCreateRecord (body, result, options)
dobo:afterCreateRecord (model, body, result, options)

For both formats, there are their counterparts that run deep inside the adapter. Only use these hooks if you know what you are doing.

Their syntax is similar to the above, with one exception: you need to put suffix .adapter after dobo:

dobo.adapter:beforeAdapterCreateRecord (model, body, options)
dobo.adapter.{modelName}:beforeAdapterCreateRecord (body, options)

Methods

(async, static) dobo:afterCountRecord(model, filter, result, options)

Hook that is called after counting records.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria that was applied when counting records

resultDoboModel.TResultCountRecord

The result of the count operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:afterCreateRecord(model, body, result, options)

Hook that is called after creating a record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

bodyobject

The body payload to be created

resultDoboModel.TResultRecord

The result of the create operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:afterFindAllRecord(model, filter, result, options)

Hook that is called after finding all records.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria applied when finding all records

resultDoboModel.TResultFindAllRecord

The result of the find all operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:afterFindOneRecord(model, filter, result, options)

Hook that is called after finding one record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria applied when finding one record

resultDoboModel.TResultFindOneRecord

The result of the find one operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:afterFindRecord(model, filter, result, options)

Hook that is called after finding records.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria applied when finding records

resultDoboModel.TResultFindRecord

The result of the find operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:afterGetRecord(model, id, result, options)

Hook that is called after getting a record by ID.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

idstring | number

The ID of the record that was retrieved

resultDoboModel.TResultGetRecord

The result of the get operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:afterRemoveRecord(model, id, result, options)

Hook that is called after removing a record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

idstring | number

The ID of the record that was removed

resultDoboModel.TResultRemoveRecord

The result of the remove operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:afterUpdateRecord(model, id, body, result, options)

Hook that is called after updating a record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

idstring | number

The ID of the record that was updated

bodyobject

The body payload that was updated

resultDoboModel.TResultUpdateRecord

The result of the update operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeCountRecord(model, filter, options)

Hook that is called before counting records.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria to apply when counting records

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeCreateRecord(model, body, options)

Hook that is called before creating a record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

bodyobject

The body payload to be created

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeFindAllRecord(model, filter, options)

Hook that is called before finding all records.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria to apply when finding all records

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeFindOneRecord(model, filter, result, options)

Hook that is called before finding one record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria to apply when finding one record

resultDoboModel.TResultFindRecord

The result of the find operation

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeFindRecord(model, filter, options)

Hook that is called before finding records.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

filterDoboModel.TFilter

The filter criteria to apply when finding records

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeGetRecord(model, id, options)

Hook that is called before getting a record by ID.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

idstring | number

The ID of the record to be retrieved

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeRemoveRecord(model, id, options)

Hook that is called before removing a record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

idstring | number

The ID of the record to be removed

optionsDoboModel.TOptions

The options object

(async, static) dobo:beforeUpdateRecord(model, id, body, options)

Hook that is called before updating a record.

Parameters:
NameTypeDescription
modelDoboModel

The model instance

idstring | number

The ID of the record to be updated

bodyobject

The body payload to be updated

optionsDoboModel.TOptions

The options object