Helper functions for model operations in the Dobo framework.
Methods
(static) buildFilterQuery(filter) → {Object}
Builds a sanitized filter query for the given filter.
| Name | Type | Description |
|---|---|---|
filter | Object | The filter object containing query parameters. |
The sanitized query object.
- Type:
- Object
(static) buildFilterSearch(filter) → {Object}
Builds a search filter from the given filter object.
| Name | Type | Description |
|---|---|---|
filter | Object | The filter object containing search parameters. |
The constructed search filter.
- Type:
- Object
(async, static) clearCache(id) → {Promise.<void>}
Clears the cache for a specific record ID and related find operations.
| Name | Type | Description |
|---|---|---|
id | string | | The ID of the record for which to clear the cache. |
- Type:
- Promise.<void>
(static) cloneOptions(optionsopt) → {DoboModel.TOptions}
Clone options object and omit some keys to avoid reference issues
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
options | DoboModel. | <optional> | {} |
Cloned options object
- Type:
- DoboModel.
TOptions
(async, static) copyAttachment(id, options) → {Promise.<Array>}
Copies attachments for a given record.
| Name | Type | Description |
|---|---|---|
id | string | | The ID of the record. |
options | Object | Additional options for copying attachments. |
The copied attachment records.
- Type:
- Promise.<Array>
(async, static) execDynHook(name, …args) → {Promise.<void>}
Executes a dynamic hook function with the provided name and arguments.
| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | The name of the dynamic hook to execute. | |
args | any | <repeatable> | Arguments to pass to the dynamic hook function. |
- Type:
- Promise.<void>
(async, static) execHook(name, …args) → {Promise.<void>}
Executes a hook function with the provided name and arguments.
| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | The name of the hook to execute. | |
args | any | <repeatable> | Arguments to pass to the hook function. |
- Type:
- Promise.<void>
(async, static) execModelHook(name, …args) → {Promise.<void>}
Executes a model hook function with the provided name and arguments.
| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | The name of the model hook to execute. | |
args | any | <repeatable> | Arguments to pass to the model hook function. |
- Type:
- Promise.<void>
(async, static) execValidation(body, optionsopt) → {Promise.<Object>}
Executes validation on the provided body with the given options.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
body | Object | The data to validate. | ||
options | DoboModel. | <optional> | {} | Validation options. |
The result of the validation.
- Type:
- Promise.<Object>
(async, static) getAttachmentPath(id, field, file, options) → {Promise.<string>}
Gets the attachment path for a given record and field.
| Name | Type | Description |
|---|---|---|
id | string | | The ID of the record. |
field | string | The field name of the attachment. |
file | string | The file name of the attachment. |
options | Object | Additional options, including dirOnly. |
The path to the attachment.
- Type:
- Promise.<string>
(async, static) getFilterAndOptions(filter, options, action) → {Promise.<{filter: DoboModel.TFilter, options: DoboModel.TOptions}>}
Prepares and returns the filter and options for a given action.
| Name | Type | Description |
|---|---|---|
filter | DoboModel. | The filter criteria. |
options | DoboModel. | The options for the action. |
action | string | The action being performed. |
The prepared filter and options.
- Type:
- Promise.<{filter: DoboModel.TFilter, options: DoboModel.TOptions}>
(async, static) getRefs(records, options) → {Promise.<void>}
Gets reference records for the given records.
| Name | Type | Description |
|---|---|---|
records | Array.<Object> | The records to get references for. |
options | Object | Additional options for fetching references. |
- Type:
- Promise.<void>
(async, static) handleAttachmentUpload(id, trigger, options) → {Promise.<void>}
Handles attachment uploads for a given record and trigger.
| Name | Type | Description |
|---|---|---|
id | string | | The ID of the record. |
trigger | string | The action trigger (e.g., 'added', 'removed'). |
options | Object | Additional options for handling the upload. |
- Type:
- Promise.<void>
(async, static) handleReq(id, trigger, optionsopt) → {Promise.<void>}
Handles a request for a given action trigger.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
id | string | | The ID of the record. | ||
trigger | string | The action trigger (e.g., 'created', 'updated', 'removed'). | ||
options | DoboModel. | <optional> | {} | Additional options for handling the request. |
- Type:
- Promise.<void>
(async, static) mergeAttachmentInfo(rec, source, options) → {Promise.<void>}
Merges attachment information into the given record.
| Name | Type | Description |
|---|---|---|
rec | Object | The record to merge attachment info into. |
source | string | The source file path of the attachment. |
options | Object | Additional options including mimeType, stats, and fullPath. |
- Type:
- Promise.<void>
(async, static) preparePagination(filter, options) → {Object}
Prepare pagination parameters for a query:
- Ensures that the limit does not exceed the maximum allowed limit.
- Ensures that the page number is within the allowed range.
- Calculates the number of records to skip based on the page and limit.
- Builds the sort order based on the provided sort input.
| Name | Type | Description |
|---|---|---|
filter | DoboModel. | The filter object containing pagination parameters. |
options | DoboModel. | Additional options for pagination. |
The prepared pagination parameters including limit, page, skip, and sort.
- Type:
- Object
(static) sanitizeQuery(query, parent) → {Object}
Sanitizes a query object by ensuring that its fields and values conform to the model's schema.
| Name | Type | Description |
|---|---|---|
query | Object | The query object to sanitize. |
parent | string | The parent field name, if applicable. |
The sanitized query object.
- Type:
- Object