DoboAction

Action class enables you to call model's method with all parameters and options in chainable methods in addition of the normal call.

Action class is created by calling model method without any parameter. The resulted class instance can be used to call model's method with all parameters and options in chainable methods.

Action class can also be created by calling model.action() method, with or without parameters. Please see the example below:

You always need to call the run() method as the last step. The run() method will return the result of the model's method call.

Constructor

new DoboAction()

Example
// method 1:
const action = await model.getRecord() // Important: no parameter passed
const result = action.id('rec-id').noHook().dataOnly(false).run()
// method 2:
const result = await model.action().getRecord('rec-id').noHook().dataOnly(false).run()
// method 3:
const result = await model.action('getRecord').id('rec-id').noHook().dataOnly(false).run()
// method 4:
const result = await model.action('getRecord', 'rec-id').noHook().dataOnly(false).run()
// Instead of chaining options as methods, you can also pass options object as the parameter to the run() method
const result = await model.action('getRecord', 'rec-id').run({ noHook: true, dataOnly: false })

Methods

_setArgs(method, args) → {void}

Internal method to set the arguments to the instance properties based on the method name and the arguments passed.

Parameters:
NameTypeDescription
methodstring

The name of the method being called

argsArray

The arguments passed to the method

Returns:
Type: 
void

body(value) → {DoboAction}

Set the body for the corresponding record. You need this for createRecord, updateRecord or upsertRecord operations. This method is chainable.

Parameters:
NameTypeDescription
valueobject

The body value to set

Returns:

The current instance for chaining

Type: 
DoboAction

(async) dispose() → {Promise.<void>}

Dispose the instance and clean up resources.

Returns:
Type: 
Promise.<void>

filter(value) → {DoboAction}

Set the filter for the corresponding record. You optionally need this for findRecord, findOneRecord or findAllRecord operations. This method is chainable.

Parameters:
NameTypeDescription
valueobject

The filter value to set

Returns:

The current instance for chaining

Type: 
DoboAction

id(value) → {DoboAction}

Set the ID for the corresponding record. You need this for updateRecord or removeRecord operations. This method is chainable.

Parameters:
NameTypeDescription
valuestring | number

The ID value to set

Returns:

The current instance for chaining

Type: 
DoboAction

options(value) → {DoboAction}

Set the options for the corresponding method. This method is chainable.

Parameters:
NameTypeDescription
valueDoboAction.TOptions

The options to set

Returns:

The current instance for chaining

Type: 
DoboAction

(async) run(value) → {Promise.<*>}

Execute the corresponding method with the set arguments and options. This method is chainable.

Parameters:
NameTypeDescription
valueDoboAction.TOptions

If set, it will override the options set by the options() method. This is useful if you want to set options at the last step.

Returns:

The result of the method execution

Type: 
Promise.<*>

Type Definitions

TMethods

Dobo model's chainable methods. Only the keys listed here are allowed to be called in chainable methods. The values are the only allowed arguments for the corresponding chainable methods.

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
createRecordArray.<string><optional>
['body']
updateRecordArray.<string><optional>
['id', 'body']
upsertRecordArray.<string><optional>
['body']
removeRecordArray.<string><optional>
['id']
getRecordArray.<string><optional>
['id']
findRecordArray.<string><optional>
['filter']
findOneRecordArray.<string><optional>
['filter']
findAllRecordArray.<string><optional>
['filter']
findAllRecordsArray.<string><optional>
['filter']

Alias of findAllRecord

countRecordArray.<string><optional>
['params']
createAggregateArray.<string><optional>
['params']
createHistogramArray.<string><optional>
['params']
createAttachmentArray.<string><optional>
['id']
findAttachmentArray.<string><optional>
['id']
getAttachmentArray.<string><optional>
['id', 'field', 'file']
listAttachmentArray.<string><optional>
['params']
removeAttachmentArray.<string><optional>
['id', 'field', 'file']
updateAttachmentArray.<string><optional>
['id']

TOptions

Allowed options for Dobo model's chainable methods. Only the keys listed here are allowed to be called in chainable methods. The values are the default values for the corresponding options.

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
truncateStringboolean<optional>
true
noResultboolean<optional>
false
noBodySanitizerboolean<optional>
false
noResultSanitizerboolean<optional>
false
noValidationboolean<optional>
false
dataOnlyboolean<optional>
true
noHookboolean<optional>
false
noModelHookboolean<optional>
false
noDynHookboolean<optional>
false
extFieldsArray<optional>
[]
fieldsArray<optional>
[]
noFlashboolean<optional>
false
hiddenArray<optional>
[]
refsArray<optional>
[]
typesArray<optional>
[]
typestring | undefined<optional>
groupstring | undefined<optional>
aggregatesArray<optional>
[]
fieldstring | undefined<optional>
queryHandlerstring | undefined<optional>
countboolean<optional>
true
noCacheboolean<optional>
true
partialboolean<optional>
true
mimeTypeboolean<optional>
true
fullPathboolean<optional>
true
statsboolean<optional>
true
dirOnlyboolean<optional>
true
setFieldstring | undefined<optional>
setFilestring | undefined<optional>
sourcestring | undefined<optional>
uriEncodedboolean<optional>
true