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)
- Source
Methods
(async, static) dobo:afterCountRecord(model, filter, result, options)
Hook that is called after counting records.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria that was applied when counting records |
result | DoboModel. | The result of the count operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:afterCreateRecord(model, body, result, options)
Hook that is called after creating a record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
body | object | The body payload to be created |
result | DoboModel. | The result of the create operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:afterFindAllRecord(model, filter, result, options)
Hook that is called after finding all records.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria applied when finding all records |
result | DoboModel. | The result of the find all operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:afterFindOneRecord(model, filter, result, options)
Hook that is called after finding one record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria applied when finding one record |
result | DoboModel. | The result of the find one operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:afterFindRecord(model, filter, result, options)
Hook that is called after finding records.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria applied when finding records |
result | DoboModel. | The result of the find operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:afterGetRecord(model, id, result, options)
Hook that is called after getting a record by ID.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
id | string | | The ID of the record that was retrieved |
result | DoboModel. | The result of the get operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:afterRemoveRecord(model, id, result, options)
Hook that is called after removing a record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
id | string | | The ID of the record that was removed |
result | DoboModel. | The result of the remove operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:afterUpdateRecord(model, id, body, result, options)
Hook that is called after updating a record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
id | string | | The ID of the record that was updated |
body | object | The body payload that was updated |
result | DoboModel. | The result of the update operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeCountRecord(model, filter, options)
Hook that is called before counting records.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria to apply when counting records |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeCreateRecord(model, body, options)
Hook that is called before creating a record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
body | object | The body payload to be created |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeFindAllRecord(model, filter, options)
Hook that is called before finding all records.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria to apply when finding all records |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeFindOneRecord(model, filter, result, options)
Hook that is called before finding one record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria to apply when finding one record |
result | DoboModel. | The result of the find operation |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeFindRecord(model, filter, options)
Hook that is called before finding records.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
filter | DoboModel. | The filter criteria to apply when finding records |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeGetRecord(model, id, options)
Hook that is called before getting a record by ID.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
id | string | | The ID of the record to be retrieved |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeRemoveRecord(model, id, options)
Hook that is called before removing a record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
id | string | | The ID of the record to be removed |
options | DoboModel. | The options object |
- Source
(async, static) dobo:beforeUpdateRecord(model, id, body, options)
Hook that is called before updating a record.
| Name | Type | Description |
|---|---|---|
model | DoboModel | The model instance |
id | string | | The ID of the record to be updated |
body | object | The body payload to be updated |
options | DoboModel. | The options object |
- Source