Class: MONGO_ADAPTER

MONGO_ADAPTER

A mongoose specific adapter which provides CRUD methods for a given model

Constructor

new MONGO_ADAPTER(optionsopt)

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for the mongo adapter

Properties
Name Type Attributes Default Description
docid string

Specifies the field which should be queried by default for .load

model Object

Mongoose model that should be used in CRUD operations by default

sort Object | string <optional>
"-createdat"

Specifies default sort logic for .query and .search queries

db_connection Object <optional>
mongoose

A custom mongoose db instance if connecting to a different mongoose instance. Will default to cached mongoose connection if not passed. If this option is defined the changeset scheam will be registered on this instance.

limit number <optional>
500

Specifies a default limit to the total documents returned in a .query and .search queries

skip number <optional>
0

Specifies a default amount of documents to skip in a .query and .search queries

population Object | string <optional>

Optional population configuration for documents returned in .load and .search queries

fields Object <optional>

Optional configuration for limiting fields that are returned in .load and .search queries

pagelength number <optional>
15

Specifies max number of documents that should appear in each sub-set for pagination

track_changes Boolean <optional>
true

Sets default track changes behavior for udpates

xss_whitelist Array.<string> <optional>
false

Configuration for XSS whitelist package. If false XSS whitelisting will be ignored

Source:

Methods

create(optionsopt, cbopt) → {Object}

Create method for adapter see _CREATE for more details

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for create

cb function <optional>
false

Callback argument. When cb is not passed function returns a Promise

Source:
Returns:

Returns a Promise when cb argument is not passed

Type
Object

delete(optionsopt, cbopt) → {Object}

Delete method for adapter see _DELETE and _DELETED for more details

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for create

Properties
Name Type Description
return_deleted Boolean

If true delete method will return the deleted document

cb function <optional>
false

Callback argument. When cb is not passed function returns a Promise

Source:
Returns:

Returns a Promise when cb argument is not passed

Type
Object

load(optionsopt, cbopt) → {Object}

Load method for adapter see _LOAD for more details

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for load

cb function <optional>
false

Callback argument. When cb is not passed function returns a Promise

Source:
Returns:

Returns a Promise when cb argument is not passed

Type
Object

query(optionsopt, cbopt) → {Object}

Query method for adapter see _QUERY and _QUERY_WITH_PAGINATION for more details

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for query

Properties
Name Type Description
paginate Boolean

When true query will return data in a paginated form

cb function <optional>
false

Callback argument. When cb is not passed function returns a Promise

Source:
Returns:

Returns a Promise when cb argument is not passed

Type
Object

Search method for adapter see _SEARCH for more details

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for query

cb function <optional>
false

Callback argument. When cb is not passed function returns a Promise

Source:
Returns:

Returns a Promise when cb argument is not passed

Type
Object

stream(optionsopt, cbopt) → {Object}

Stream method for adapter see _STREAM for more details

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for stream

cb function <optional>
false

Callback argument. When cb is not passed function returns a Promise

Source:
Returns:

Returns a Promise when cb argument is not passed

Type
Object

update(optionsopt, cbopt) → {Object}

Update method for adapter see _UPDATE, _UPDATED and _UPDATE_ALL for more details

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Configurable options for update

Properties
Name Type Description
return_updated Boolean

If true update method will return the updated document instead of an update status message

multi Boolean

If true a multiple document update will be perfomed

cb function <optional>
false

Callback argument. When cb is not passed function returns a Promise

Source:
Returns:

Returns a Promise when cb argument is not passed

Type
Object