Module: Model/Default

Methods


<static> add(data)

Starts add routine
Parameters:
Name Type Description
data object data
Returns:
Promise
Type
Promise

<static> countWithFilter(filter)

Counts record method
Parameters:
Name Type Description
filter object | array filter rules
Returns:
Promise
Type
Promise

<static> getOne(id, population)

Retrieves one record by primary key If versioning ON, it retrieves __latest and not __closed
Parameters:
Name Type Description
id string primary key
population Array optional if needed population of some fields
Returns:
Promise
Type
Promise

<static> getOneByID(ID)

Retrieves one record by unique number ID If versioning ON, it retrieves __latest and not __closed
Parameters:
Name Type Description
ID number some unique number identificator
Returns:
Promise of document, if increment is OFF - then Promise.resolve(null)
Type
Promise

<static> getOneRaw(id)

Retrieves one record by primary key, without any restriction
Parameters:
Name Type Description
id string primary key
Returns:
Promise
Type
Promise

<static> list(skip, size, sorter, filter)

List record method
Parameters:
Name Type Description
skip number number of skiped records
size number length of return list
sorter Object sorter rules
filter Object | Array filter rules
Returns:
Promise
Type
Promise

<static> listAll()

List all records from collection If Versioning is ON restricts to __latest and not __closed By default sorts by _id in DESC
Returns:
Promise
Type
Promise

<static> listAllAndPopulate(populate)

List all record in collection and populates If Versioning is ON restricts to __latest and not __closed By default sorts by _id in DESC
Parameters:
Name Type Description
populate object | array populate rules
Returns:
Promise
Type
Promise

<async, static> listAndCount(skip, size, sorter, filter, search, populate)

List record in collection and populates, with count of total founded records By default sorts by _id in DESC
Parameters:
Name Type Description
skip number number of skiped records
size number length of return list
sorter object sorter rules
filter object | array filter rules
search object | array search rules
populate object populate rules
Returns:
{list, count, pages}
Type
Promise

<static> listAndPopulate(skip, size, sorter, filter, populate)

List record and populate method
Parameters:
Name Type Description
skip number number of skiped records
size number length of return list
sorter object sorter rules
filter object | array filter rules
populate object populate rules
Returns:
Promise
Type
Promise

<static> listByField(field, list, filter, populate)

Returns list of items with specific values in specific field, optionaly filtered
Parameters:
Name Type Description
field string name of the field to search in
list array list of 'id' field values
filter object | array filter rules
populate object populate rules
Returns:
Promise
Type
Promise

<static> makeQuery(method, filter)

Common query with filtering constructor for generic method
Parameters:
Name Type Description
method string name of the method
filter object | array filtering rules object
Returns:
mongoose query object
Type
Query

<static> sanitizeInput(input)

Sanitize input
Parameters:
Name Type Description
input object data
Returns:
data;
Type
object

<static> update(filter, data, many)

Starts update routine
Parameters:
Name Type Default Description
filter object search criteria
data object data
many boolean false if true will affect all records according to filter
Returns:
Promise
Type
Promise

<inner> close()

Closes document and saves it This is replaces remove when Versioning is ON
Returns:
ID
Type
number

<inner> getID()

Returns incremental ID for this doc
Returns:
ID
Type
number