Methods

(async) factory(pkgName) → {class}

Plugin factory

Parameters:
NameTypeDescription
pkgNamestring

NPM package name

Returns:
Type: 
class

Type Definitions

TPropType

Type:
  • Object
Properties
NameTypeDefaultDescription
integerObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
number
smallintObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
number
textObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
string
textTypestring<optional>
string
valuesArray.<string><optional>
['text', 'mediumtext', 'longtext']
stringObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
string
maxLengthmaxLength<optional>
255
minLengthminLength<optional>
0
floatObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
number
doubleObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
number
booleanObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
boolean
datetimeObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
date
dateObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
date
timeObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
date
timestampObject
Properties
NameTypeAttributesDefaultDescription
validatorstring<optional>
timestamp
objectObject{}
arrayObject{}

TRecordCountOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
dataOnlyboolean<optional>
true

If true (default) returns array of records. Otherwise TFindRecordResult

noCacheboolean<optional>
true

If true (default), result set won't be cached. This will overwrite model's cacheable property. Only applicable if bajo-cache is loaded

noHookboolean<optional>
false

If true, no model's hook will be executed

noFeatureHookboolean<optional>
false

If true, no model's feature hook will be executed

TRecordCreateOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
dataOnlyboolean<optional>
true

If true (default) returns record's object. Otherwise TRecordCreateResult

noHookboolean<optional>
false

If true, no model's hook will be executed

noFeatureHookboolean<optional>
false

If true, no model's feature hook will be executed

noValidationboolean<optional>
false

If true, no validation of data payload performed

noCheckUniqueboolean<optional>
false

If true, no unique validation for ID performed

noSanitizeboolean<optional>
false

If true, accept data payload as is without sanitization

noResultboolean<optional>
false

If true, returns nothing

truncateStringboolean<optional>
true

If true (default), string is truncated to its schema's maxLemngth

fieldsboolean<optional>
[]

If not empty, return only these fields EXCLUDING hidden fields

hiddenboolean<optional>
[]

Additional fields to hide, in addition the one set in model's schema

forceNoHiddenboolean<optional>
false

If true, hidden fields will be ignored and ALL fields will be returned

TRecordFilter

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
querystring | Object<optional>
{}

Query definition. See query-language for more

limitnumber

Max number of records per page

pagenumber

Which page is the returned records currently at

skipnumber

Records to skip

sortTRecordSort

Sort order info

TRecordFindOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
dataOnlyboolean<optional>
true

If true (default) returns array of records. Otherwise TFindRecordResult

countboolean<optional>
false

If true and dataOnly is also true, the total number of records found will be returned

noCacheboolean<optional>
true

If true (default), result set won't be cached. This will overwrite model's cacheable property. Only applicable if bajo-cache is loaded

noHookboolean<optional>
false

If true, no model's hook will be executed

noFeatureHookboolean<optional>
false

If true, no model's feature hook will be executed

fieldsboolean<optional>
[]

If not empty, return only these fields EXCLUDING hidden fields

hiddenboolean<optional>
[]

Additional fields to hide, in addition the one set in model's schema

forceNoHiddenboolean<optional>
false

If true, hidden fields will be ignored and ALL fields will be returned

TRecordFindResult

Type:
  • Object
Properties
NameTypeDescription
dataArray.<Object>

Array of returned records

successboolean

Whether operation is successfull or failed

pagenumber

Which page is the returned records currently at

limitnumber

Max number of records per page

countnumber

Total number of records returned

pagesnumber

Total number of pages returned

TRecordGetOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
dataOnlyboolean<optional>
true

If true (default) returns array of records. Otherwise TFindRecordResult

countboolean<optional>
false

If true and dataOnly is also true, the total number of records found will be returned

noCacheboolean<optional>
true

If true (default), result set won't be cached. This will overwrite model's cacheable property. Only applicable if bajo-cache is loaded

noHookboolean<optional>
false

If true, no model's hook will be executed

noFeatureHookboolean<optional>
false

If true, no model's feature hook will be executed

fieldsboolean<optional>
[]

If not empty, return only these fields EXCLUDING hidden fields

hiddenboolean<optional>
[]

Additional fields to hide, in addition the one set in model's schema

forceNoHiddenboolean<optional>
false

If true, hidden fields will be ignored and ALL fields will be returned

TRecordGetResult

Type:
  • Object
Properties
NameTypeDescription
dataObject

Returned record

successboolean

Whether operation is successfull or failed

TRecordPagination

Type:
  • Object
Properties
NameTypeDescription
limitnumber

Number of records per page

pagenumber

Page number

skipnumber

Records to skip

sortTRecordSort

Sort order

TRecordRemoveOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
dataOnlyboolean<optional>
true

If true (default) returns deleted record. Otherwise TRecordRemoveResult

noHookboolean<optional>
false

If true, no model's hook will be executed

noFeatureHookboolean<optional>
false

If true, no model's feature hook will be executed

noResultboolean<optional>
false

If true, returns nothing

fieldsboolean<optional>
[]

If not empty, return only these fields EXCLUDING hidden fields

hiddenboolean<optional>
[]

Additional fields to hide, in addition the one set in model's schema

forceNoHiddenboolean<optional>
false

If true, hidden fields will be ignored and ALL fields will be returned

TRecordSort

Key value pairs used as sort information:

  • Key represent model's field name
  • value represent its sort order: 1 for ascending order, and -1 for descending order

Example: to sort by firstName (ascending) and lastName (descending)

const sort = {
  firstName: 1,
  lastName: -1
}
Type:

TRecordSortKey

Type:
  • string

TRecordUpdateOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
dataOnlyboolean<optional>
true

If true (default) returns record's object. Otherwise TRecordUpdateResult

noHookboolean<optional>
false

If true, no model's hook will be executed

noFeatureHookboolean<optional>
false

If true, no model's feature hook will be executed

noValidationboolean<optional>
false

If true, no validation of data payload performed

noCheckUniqueboolean<optional>
false

If true, no unique validation for ID performed

noSanitizeboolean<optional>
false

If true, accept data payload as is without sanitization

noResultboolean<optional>
false

If true, returns nothing

truncateStringboolean<optional>
true

If true (default), string is truncated to its schema's maxLemngth

partialboolean<optional>
true

If true (default), only updated values are saved. Otherwise replace all existing values with given payload

fieldsboolean<optional>
[]

If not empty, return only these fields EXCLUDING hidden fields

hiddenboolean<optional>
[]

Additional fields to hide, in addition the one set in model's schema

forceNoHiddenboolean<optional>
false

If true, hidden fields will be ignored and ALL fields will be returned

TValidator

Type:
  • Object
Properties

TValidatorBoolean

Type:
  • Array.<string>
Properties
NameTypeDefaultDescription
0stringfalsy
1stringsensitive
2stringtruthy

TValidatorDate

Type:
  • Array.<string>
Properties
NameTypeDefaultDescription
0stringgreater
1stringiso
2stringless
2stringmax
2stringmin

TValidatorNumber

Type:
  • Array.<string>
Properties
NameTypeDefaultDescription
0stringgreat
1stringless
2stringmax
3stringmin
4stringmultiple
5stringnegative
6stringport
7stringpositive
8stringsign
9stringunsafe

TValidatorString

Type:
  • Array.<string>
Properties
NameTypeDefaultDescription
0stringalphanum
1stringbase64
2stringcase
3stringcreditCard
4stringdataUri
5stringemail
6stringguid
7stringuuid
8stringhex
9stringhostname
10stringinsenstive
11stringip
12stringisoDate
13stringisoDuration
14stringlength
15stringlowercase
16stringmax
17stringmin
18stringnormalize
19stringpattern
20stringregex
21stringreplace
22stringtoken
23stringtrim
24stringtruncate
25stringupercase
26stringuri

TValidatorTimestamp

Type:
  • Array.<string>
Properties
NameTypeDefaultDescription
0stringtimestamp