Skip to content

Latest commit

 

History

History
1373 lines (1065 loc) · 83.6 KB

api.md

File metadata and controls

1373 lines (1065 loc) · 83.6 KB

Classes

LOKI_ADAPTER : Loki_Adapter

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

MONGO_ADAPTER : Mongo_Adapter

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

SQL_ADAPTER : SQL_Adapter

A sequelize SQL specific adapter which provides CRUD methods for a given model

CURSOR : Cursor

A simple cursor-like implementation that combines generator and stream functionality. Cursor exposes all the normal stream methods such as pipe, unpipe, on, once etc as well as an initialize method that returns a generator and allows for documents to be iteratively resolved. Using both the generator based cursor interface and stream interface concurrently is not recommended as both utilize the TransformStream on data, on error and on finish events and as such will likely cause unpredictable behavior

DB_ADAPTER_INTERFACE

Interface class - defines properties and property types that should exist within constructed classes

Functions

_QUERY(options, cb)

Convenience method for .find loki method

_STREAM(options, cb)

Convenience method for returning a stream of loki data

_QUERY_WITH_PAGINATION(options, cb)

Convenience method for .find loki method with built in pagination of data

_SEARCH(options, cb)

Convenience method for .find loki method with built in query builder functionality

_LOAD(options, cb)

Convenience method for .findOne or .findById lowkie methods

GENERATE_PATCH(data)function

Creates a lowkie update operation

GENERATE_PUT(data)Object

Returns a cleaned object for a full document update

_UPDATE(options, cb)

Convenience method for .update loki method

_UPDATED(options, cb)

Convenience method for .findAndUpdate lowkie method (returns updated document instead of normal loki update status object)

_UPDATE_ALL(options, cb)

Convenience method for .update with the multi options set to true for multiple document updates

_CREATE(options, cb)

Convenience method for .create lowkie method

_DELETE(options, cb)

Convenience method for .remove lowkie method

_DELETED(options, cb)

Convenience method for .remove lowkie method but returns the deleted document

_QUERY(options, cb)

Convenience method for .find mongo method

_STREAM(options, cb)

Convenience method for returning a stream of mongo data

_QUERY_WITH_PAGINATION(options, cb)

Convenience method for .find mongo method with built in pagination of data

_SEARCH(options, cb)

Convenience method for .find mongo method with built in query builder functionality

_LOAD(options, cb)

Convenience method for .findOne or .findById mongoose methods

GENERATE_PATCH(data)Object

Creates a mongoose update operation that only uses $set and $push

GENERATE_PUT(data)Object

Returns a cleaned object for a full document update

_UPDATE(options, cb)

Convenience method for .update mongo method

_UPDATED(options, cb)

Convenience method for .findAndUpdate mongoose method (returns updated document instead of normal mongo update status object)

_UPDATE_ALL(options, cb)

Convenience method for .update with the multi options set to true for multiple document updates

_CREATE(options, cb)

Convenience method for .create mongoose method

_DELETE(options, cb)

Convenience method for .remove mongoose method

_DELETED(options, cb)

Convenience method for .remove mongoose method but returns the deleted document

GENERATE_SELECT(fields)

Takes a set of fields either as a comma delimited list or a mongoose style fields object and converts them into a sequelize compatible array

_QUERY(options, cb)

Convenience method for .findAll sequelize method

_STREAM(options, cb)

Convenience method for returning a stream of sql data. Since sequelize does not expose a cursor or stream method this is an implementation of a cursor on top of a normal SQL query

_QUERY_WITH_PAGINATION(options, cb)

Convenience method for .findAll SQL method with built in pagination of data

_SEARCH(options, cb)

Convenience method for .findAll SQL method with built in query builder functionality

_LOAD(options, cb)

Convenience method for .findOne sequelize methods

_UPDATE(options, cb)

Convenience method for .update SQL method

_UPDATED(options, cb)

Convenience method for .update + .findOne sequelize method (returns updated document instead of normal number updated status)

_UPDATE_ALL(options, cb)

Convenience method for .update for multiple document updates

_CREATE(options, cb)

Convenience method for .create sequelize method

_DELETE(options, cb)

Convenience method for .destroy sequelize method

_DELETED(options, cb)

Convenience method for .destroy sequelize method but returns the deleted document

_RAW(options, cb)

Convenience method for .query sequelize method that allows for raw SQL queries

defaultSuccess(data)*

A default on success function for each iteration of cursor

defaultError(e)Object

A default on error function for each iteration of cursor

LOKI_ADAPTER : Loki_Adapter

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

Kind: global class

new LOKI_ADAPTER([options])

Param Type Default Description
[options] Object {} Configurable options for the loki adapter
options.docid string Specifies the field which should be queried by default for .load
options.model Object Mongoose model that should be used in CRUD operations by default
[options.sort] Object | string "-createdat" Specifies default sort logic for .query and .search queries
[options.db_connection] Object lowkie A custom lowkie db instance if connecting to a different lowkie instance. Will default to cached lowkie connection if not passed. If this option is defined the changeset scheam will be registered on this instance.
[options.limit] number 500 Specifies a default limit to the total documents returned in a .query and .search queries
[options.skip] number 0 Specifies a default amount of documents to skip in a .query and .search queries
[options.population] Object | string Optional population configuration for documents returned in .load and .search queries
[options.fields] Object Optional configuration for limiting fields that are returned in .load and .search queries
[options.pagelength] number 15 Specifies max number of documents that should appear in each sub-set for pagination
[options.track_changes] Boolean true Sets default track changes behavior for udpates
[options.xss_whitelist] Array.<string> false Configuration for XSS whitelist package. If false XSS whitelisting will be ignored

lokI_ADAPTER.query([options], [cb]) ⇒ Object

Query method for adapter see _QUERY and _QUERY_WITH_PAGINATION for more details

Kind: instance method of LOKI_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for query
options.paginate Boolean When true query will return data in a paginated form
[cb] function false Callback argument. When cb is not passed function returns a Promise

lokI_ADAPTER.search([options], [cb]) ⇒ Object

Search method for adapter see _SEARCH for more details

Kind: instance method of LOKI_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for query
[cb] function false Callback argument. When cb is not passed function returns a Promise

lokI_ADAPTER.stream([options], [cb]) ⇒ Object

Stream method for adapter see _STREAM for more details

Kind: instance method of LOKI_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for stream
[cb] function false Callback argument. When cb is not passed function returns a Promise

lokI_ADAPTER.load([options], [cb]) ⇒ Object

Load method for adapter see _LOAD for more details

Kind: instance method of LOKI_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for load
[cb] function false Callback argument. When cb is not passed function returns a Promise

lokI_ADAPTER.update([options], [cb]) ⇒ Object

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

Kind: instance method of LOKI_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for update
options.return_updated Boolean If true update method will return the updated document instead of an update status message
options.multi Boolean If true a multiple document update will be perfomed
[cb] function false Callback argument. When cb is not passed function returns a Promise

lokI_ADAPTER.create([options], [cb]) ⇒ Object

Create method for adapter see _CREATE for more details

Kind: instance method of LOKI_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for create
[cb] function false Callback argument. When cb is not passed function returns a Promise

lokI_ADAPTER.delete([options], [cb]) ⇒ Object

Delete method for adapter see _DELETE and _DELETED for more details

Kind: instance method of LOKI_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for create
options.return_deleted Boolean If true delete method will return the deleted document
[cb] function false Callback argument. When cb is not passed function returns a Promise

MONGO_ADAPTER : Mongo_Adapter

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

Kind: global class

new MONGO_ADAPTER([options])

Param Type Default Description
[options] Object {} Configurable options for the mongo adapter
options.docid string Specifies the field which should be queried by default for .load
options.model Object Mongoose model that should be used in CRUD operations by default
[options.sort] Object | string "-createdat" Specifies default sort logic for .query and .search queries
[options.db_connection] Object 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.
[options.limit] number 500 Specifies a default limit to the total documents returned in a .query and .search queries
[options.skip] number 0 Specifies a default amount of documents to skip in a .query and .search queries
[options.population] Object | string Optional population configuration for documents returned in .load and .search queries
[options.fields] Object Optional configuration for limiting fields that are returned in .load and .search queries
[options.pagelength] number 15 Specifies max number of documents that should appear in each sub-set for pagination
[options.track_changes] Boolean true Sets default track changes behavior for udpates
[options.xss_whitelist] Array.<string> false Configuration for XSS whitelist package. If false XSS whitelisting will be ignored

mongO_ADAPTER.query([options], [cb]) ⇒ Object

Query method for adapter see _QUERY and _QUERY_WITH_PAGINATION for more details

Kind: instance method of MONGO_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for query
options.paginate Boolean When true query will return data in a paginated form
[cb] function false Callback argument. When cb is not passed function returns a Promise

mongO_ADAPTER.search([options], [cb]) ⇒ Object

Search method for adapter see _SEARCH for more details

Kind: instance method of MONGO_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for query
[cb] function false Callback argument. When cb is not passed function returns a Promise

mongO_ADAPTER.stream([options], [cb]) ⇒ Object

Stream method for adapter see _STREAM for more details

Kind: instance method of MONGO_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for stream
[cb] function false Callback argument. When cb is not passed function returns a Promise

mongO_ADAPTER.load([options], [cb]) ⇒ Object

Load method for adapter see _LOAD for more details

Kind: instance method of MONGO_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for load
[cb] function false Callback argument. When cb is not passed function returns a Promise

mongO_ADAPTER.update([options], [cb]) ⇒ Object

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

Kind: instance method of MONGO_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for update
options.return_updated Boolean If true update method will return the updated document instead of an update status message
options.multi Boolean If true a multiple document update will be perfomed
[cb] function false Callback argument. When cb is not passed function returns a Promise

mongO_ADAPTER.create([options], [cb]) ⇒ Object

Create method for adapter see _CREATE for more details

Kind: instance method of MONGO_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for create
[cb] function false Callback argument. When cb is not passed function returns a Promise

mongO_ADAPTER.delete([options], [cb]) ⇒ Object

Delete method for adapter see _DELETE and _DELETED for more details

Kind: instance method of MONGO_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for create
options.return_deleted Boolean If true delete method will return the deleted document
[cb] function false Callback argument. When cb is not passed function returns a Promise

SQL_ADAPTER : SQL_Adapter

A sequelize SQL specific adapter which provides CRUD methods for a given model

Kind: global class

new SQL_ADAPTER(options)

Constructor for SQL_Adapter

Param Type Default Description
options Object Configurable options for the SQL adapter
options.db_connection Object | Array.<string> Either a instantiated instance of Sequelize or the connection details for a instance as an array of ordered arguments or options object
[options.db_connetion.db_name] string Name of the database (only used if instantiating a new Sequelize instance)
[options.db_connetion.db_user] string Username for the database (only used if instantiating a new Sequelize instance)
[options.db_connetion.db_password] string Password for the database (only used if instantiating a new Sequelize instance)
[options.db_connetion.db_options] string Options for connection to the database ie. port, hostname (only used if instantiating a new Sequelize instance)
[options.docid] string "&quot;id&quot;" Specifies the field which should be queried by default for .load
options.model Object | Array.<Object> Either a registered sequelize model or if options.model is an Array it will be treated as the arguments to define a sequelize model
[options.sort] Object | string "createdat DESC" Specifies default sort logic for .query and .search queries
[options.limit] number 500 Specifies a default limit to the total documents returned in a .query and .search queries
[options.skip] number 0 Specifies a default amount of documents to skip in a .query and .search queries
[options.population] Object | Array.<Object> [] Optional population configuration for documents returned in .load and .search queries (see sequelize include for proper formatting)
[options.fields] Object Optional configuration for limiting fields that are returned in .load and .search queries
[options.pagelength] number 15 Specifies max number of documents that should appear in each sub-set for pagination
[options.track_changes] Boolean true Sets default track changes behavior for udpates
[options.xss_whitelist] Array.<string> false Configuration for XSS whitelist package. If false XSS whitelisting will be ignored

sqL_ADAPTER.sync([options], [cb]) ⇒ Object

Sync defined sequelize models with SQL db

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for sequelize sync method
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.query([options], [cb]) ⇒ Object

Query method for adapter see _QUERY and _QUERY_WITH_PAGINATION for more details

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for query
options.paginate Boolean When true query will return data in a paginated form
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.search([options], [cb]) ⇒ Object

Search method for adapter see _SEARCH for more details

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for query
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.stream([options], [cb]) ⇒ Object

Stream method for adapter see _STREAM for more details

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for stream
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.load([options], [cb]) ⇒ Object

Load method for adapter see _LOAD for more details

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for load
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.update([options], [cb]) ⇒ Object

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

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for update
options.return_updated Boolean If true update method will return the updated document instead of an update status message
options.multi Boolean If true a multiple document update will be perfomed
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.create([options], [cb]) ⇒ Object

Create method for adapter see _CREATE for more details

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for create
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.delete([options], [cb]) ⇒ Object

Delete method for adapter see _DELETE and _DELETED for more details

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
[options] Object {} Configurable options for create
options.return_deleted Boolean If true delete method will return the deleted document
[cb] function false Callback argument. When cb is not passed function returns a Promise

sqL_ADAPTER.raw(options, cb) ⇒ Object

Raw query method for adapter see _RAW for more details

Kind: instance method of SQL_ADAPTER
Returns: Object - Returns a Promise when cb argument is not passed

Param Type Default Description
options Object Configurable options for raw query
cb function false Callback argument. When cb is not passed function returns a Promise

CURSOR : Cursor

A simple cursor-like implementation that combines generator and stream functionality. Cursor exposes all the normal stream methods such as pipe, unpipe, on, once etc as well as an initialize method that returns a generator and allows for documents to be iteratively resolved. Using both the generator based cursor interface and stream interface concurrently is not recommended as both utilize the TransformStream on data, on error and on finish events and as such will likely cause unpredictable behavior

Kind: global class
Extends: TranformStream

new CURSOR([options])

Constructor for Cursor class

Param Type Default Description
[options] Object {} Configurable options for cursor (see TransformStream documentation for more details)
options.objectMode Boolean Unlike a normal transform stream the cursor class is meant for documents and as such objectMode will always be true unless explicitly declared as false at initialization

cursoR._next() ⇒ Object

Internally used _next method (this should never be accessed directly). Resumes the transform stream and resolves the next document before pausing the stream

Kind: instance method of CURSOR
Returns: Object - Returns a Promise which resolves with the next document written to the stream

cursoR.initialize([onSuccess], [onError]) ⇒ function

Initializes the cursor interface. Once initialized the generator will yield a single document with each next call. The behavior can be modified by passing an onSuccess function as the first argument with each next call. Once cursor is initialized the streams finish, data and error events will have registered listeners

Kind: instance method of CURSOR
Returns: function - Returns a generator that iteratively resolves the documents written to the stream

Param Type Default Description
[onSuccess] function defaultSuccess A default function to be called on each successful .next call. This function can be temporarily overridden by passing a function in the .next call
[onError] function defaultError A default function to be called when a .next call results in an rejection

DB_ADAPTER_INTERFACE

Interface class - defines properties and property types that should exist within constructed classes

Kind: global class

new DB_ADAPTER_INTERFACE([options])

Creates an interface

Param Type Default Description
[options] Object {} A set of properties defined by keys with their allowed types as values. Each property will be required by newly constructed classes from this interface

dB_ADAPTER_INTERFACE.create([options]) ⇒ Object

Constructs a new object with a prototype defined by the .adapter ensuring that instantiated class conforms to interface requirements

Kind: instance method of DB_ADAPTER_INTERFACE
Returns: Object - Returns an instantiated adapter class

Param Type Default Description
[options] Object {} Values to be passed to class constructor (.adapter should be reserved for either customer class or string that matches key in ADAPTERS)
options.adapter string | function Required to specify type of adapter to be constructed or a class constructor that can be instantiated with new keyword
options.db string | function Alias for options.adapter. If options.db is defined options.adapter will be ignored

_QUERY(options, cb)

Convenience method for .find loki method

Kind: global function

Param Type Default Description
options Object Options for the loki query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.population] Object | string this.population The lowkie population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for query

_STREAM(options, cb)

Convenience method for returning a stream of loki data

Kind: global function

Param Type Default Description
options Object Options for the loki query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.population] Object | string this.population The lowkie population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for stream

_QUERY_WITH_PAGINATION(options, cb)

Convenience method for .find loki method with built in pagination of data

Kind: global function

Param Type Default Description
options Object Options for the loki query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.pagelength] number this.pagelength Defines the max length of each sub-set of data
[options.population] Object | string this.population The lowkie population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for query

_SEARCH(options, cb)

Convenience method for .find loki method with built in query builder functionality

Kind: global function

Param Type Default Description
options Object Options for the loki query
[options.query] Object | string The query that should be used for the database search. If this value is a string it will be treated as a delimited list of values to use in query
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.pagelength] number this.pagelength Defines the max length of each sub-set of data
[options.population] Object | string this.population The lowkie population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
[options.search] Array.<string> this.searchfields Used in building the query. A separate $or statement is appended into query array for each search field specified ie. ['a','b'] => { $or: [{a: ..., b ...}] }
[options.delimeter] string "&quot;
[options.docid] string "this.docid" When using options.values this specifies the name of the field that should be matched
[options.values] string A comma separated list of values to be queried against docid or "_id" if docid is not specified
options.paginate Boolean If true documents will be returned in a paginated format
cb function Callback function for query

_LOAD(options, cb)

Convenience method for .findOne or .findById lowkie methods

Kind: global function

Param Type Default Description
options Object Configurable options for loki query
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.population] Object | string this.population The lowkie population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.docid] string "&quot;_id&quot;" A field that should be queried will default to "_id"
options.query Object | string | number If value is an object query will be set to the value otherwise a query will be built based on options.docid and any other value provided in options.query
cb function Callback function for load

GENERATE_PATCH(data) ⇒ function

Creates a lowkie update operation

Kind: global function
Returns: function - Returns a function that is used in loki update operation

Param Type Description
data Object Any fields that should be updated as part of patch

GENERATE_PUT(data) ⇒ Object

Returns a cleaned object for a full document update

Kind: global function
Returns: Object - Returns original object with reserved fields removed

Param Type Description
data Object A full document with updated data for put

_UPDATE(options, cb)

Convenience method for .update loki method

Kind: global function

Param Type Default Description
options Object Configurable options for loki update
options.isPatch Boolean If true the update will be treated as a patch instead of a full document update
options.updatedoc Object Either specific fields to update in the case of a patch otherwise the entire updatedated document
options.id string The loki _id of the document that should be updated
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.track_changes] Boolean If false changes will not be tracked
[options.ensure_changes] Boolean If true changeset generation and saving is blocking and errors will cause entire operation to fail
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
cb function Callback function for update

_UPDATED(options, cb)

Convenience method for .findAndUpdate lowkie method (returns updated document instead of normal loki update status object)

Kind: global function

Param Type Default Description
options Object Configurable options for loki update
options.isPatch Boolean If true the update will be treated as a patch instead of a full document update
options.updatedoc Object Either specific fields to update in the case of a patch otherwise the entire updated document
options.id string The loki _id of the document that should be updated
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.track_changes] Boolean If false changes will not be tracked
[options.ensure_changes] Boolean If true changeset generation and saving is blocking and errors will cause entire operation to fail
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
cb function Callback function for update

_UPDATE_ALL(options, cb)

Convenience method for .update with the multi options set to true for multiple document updates

Kind: global function

Param Type Default Description
options Object Configurable options for loki update with multi true
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
options.query Object Query that should be used in update
[options.updatequery] Object Alias for options.query if options.query is set this option is ignored
options.updateattributes Object A loki update formatted object
[options.updatedoc] Object Object specifying fields to update with new values this object will be formatted as a patch update. If options.updateattributes is set this option is ignored
cb function Callback function for update all

_CREATE(options, cb)

Convenience method for .create lowkie method

Kind: global function

Param Type Default Description
options Object Configurable options for loki create
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
[options.newdoc] Object | Array.<Object> options The document that should be created. If newdoc option is not passed it is assumed that the entire options object is the document
options.bulk_create Boolean If true and options.newdoc is an array each index will be treated as an individual document and be bulk inserted
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.xss_whitelist] Object this.xss_whitelist XSS white-list configuration for xss npm module
cb function Callback function for create

_DELETE(options, cb)

Convenience method for .remove lowkie method

Kind: global function

Param Type Default Description
options Object Configurable options for loki delete
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
options.deleteid string The loki id of the document that should be removed
options.id string If options.deleteid is provided this value is ignored - alias for options.deleteid
cb function Callback function for delete

_DELETED(options, cb)

Convenience method for .remove lowkie method but returns the deleted document

Kind: global function

Param Type Default Description
options Object Configurable options for loki delete
[options.model] Object this.model The lowkie model for query will default to the this.model value if not defined
options.deleteid string The loki id of the document that should be removed
options.id string If options.deleteid is provided this value is ignored - alias for options.deleteid
cb function Callback function for delete

_QUERY(options, cb)

Convenience method for .find mongo method

Kind: global function

Param Type Default Description
options Object Options for the mongo query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.population] Object | string this.population The mongoose population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for query

_STREAM(options, cb)

Convenience method for returning a stream of mongo data

Kind: global function

Param Type Default Description
options Object Options for the mongo query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.population] Object | string this.population The mongoose population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for stream

_QUERY_WITH_PAGINATION(options, cb)

Convenience method for .find mongo method with built in pagination of data

Kind: global function

Param Type Default Description
options Object Options for the mongo query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.pagelength] number this.pagelength Defines the max length of each sub-set of data
[options.population] Object | string this.population The mongoose population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for query

_SEARCH(options, cb)

Convenience method for .find mongo method with built in query builder functionality

Kind: global function

Param Type Default Description
options Object Options for the mongo query
[options.query] Object | string The query that should be used for the database search. If this value is a string it will be treated as a delimited list of values to use in query
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.pagelength] number this.pagelength Defines the max length of each sub-set of data
[options.population] Object | string this.population The mongoose population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
[options.search] Array.<string> this.searchfields Used in building the query. A separate $or statement is appended into query array for each search field specified ie. ['a','b'] => { $or: [{a: ..., b ...}] }
[options.delimeter] string "&quot;
[options.docid] string "this.docid" When using options.values this specifies the name of the field that should be matched
[options.values] string A comma separated list of values to be queried against docid or "_id" if docid is not specified
options.paginate Boolean If true documents will be returned in a paginated format
cb function Callback function for query

_LOAD(options, cb)

Convenience method for .findOne or .findById mongoose methods

Kind: global function

Param Type Default Description
options Object Configurable options for mongo query
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.population] Object | string this.population The mongoose population for query will default to the this.population value if not defined
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.docid] string "&quot;_id&quot;" A field that should be queried will default to "_id"
options.query Object | string | number If value is an object query will be set to the value otherwise a query will be built based on options.docid and any other value provided in options.query
cb function Callback function for load

GENERATE_PATCH(data) ⇒ Object

Creates a mongoose update operation that only uses $set and $push

Kind: global function
Returns: Object - Returns an object with $set and $push properties

Param Type Description
data Object Any fields that should be updated as part of patch

GENERATE_PUT(data) ⇒ Object

Returns a cleaned object for a full document update

Kind: global function
Returns: Object - Returns original object with reserved fields removed

Param Type Description
data Object A full document with updated data for put

_UPDATE(options, cb)

Convenience method for .update mongo method

Kind: global function

Param Type Default Description
options Object Configurable options for mongo update
options.isPatch Boolean If true the update will be treated as a patch instead of a full document update
options.updatedoc Object Either specific fields to update in the case of a patch otherwise the entire updatedated document
options.id string The mongo _id of the document that should be updated
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.track_changes] Boolean If false changes will not be tracked
[options.ensure_changes] Boolean If true changeset generation and saving is blocking and errors will cause entire operation to fail
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
cb function Callback function for update

_UPDATED(options, cb)

Convenience method for .findAndUpdate mongoose method (returns updated document instead of normal mongo update status object)

Kind: global function

Param Type Default Description
options Object Configurable options for mongo update
options.isPatch Boolean If true the update will be treated as a patch instead of a full document update
options.updatedoc Object Either specific fields to update in the case of a patch otherwise the entire updated document
options.id string The mongo _id of the document that should be updated
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.track_changes] Boolean If false changes will not be tracked
[options.ensure_changes] Boolean If true changeset generation and saving is blocking and errors will cause entire operation to fail
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
cb function Callback function for update

_UPDATE_ALL(options, cb)

Convenience method for .update with the multi options set to true for multiple document updates

Kind: global function

Param Type Default Description
options Object Configurable options for mongo update with multi true
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
options.query Object Query that should be used in update
[options.updatequery] Object Alias for options.query if options.query is set this option is ignored
options.updateattributes Object A mongo update formatted object
[options.updatedoc] Object Object specifying fields to update with new values this object will be formatted as a patch update. If options.updateattributes is set this option is ignored
cb function Callback function for update all

_CREATE(options, cb)

Convenience method for .create mongoose method

Kind: global function

Param Type Default Description
options Object Configurable options for mongo create
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
[options.newdoc] Object | Array.<Object> options The document that should be created. If newdoc option is not passed it is assumed that the entire options object is the document
options.bulk_create Boolean If true and options.newdoc is an array each index will be treated as an individual document and be bulk inserted
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.xss_whitelist] Object this.xss_whitelist XSS white-list configuration for xss npm module
cb function Callback function for create

_DELETE(options, cb)

Convenience method for .remove mongoose method

Kind: global function

Param Type Default Description
options Object Configurable options for mongo delete
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
options.deleteid string The mongo id of the document that should be removed
options.id string If options.deleteid is provided this value is ignored - alias for options.deleteid
cb function Callback function for delete

_DELETED(options, cb)

Convenience method for .remove mongoose method but returns the deleted document

Kind: global function

Param Type Default Description
options Object Configurable options for mongo delete
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
options.deleteid string The mongo id of the document that should be removed
options.id string If options.deleteid is provided this value is ignored - alias for options.deleteid
cb function Callback function for delete

GENERATE_SELECT(fields)

Takes a set of fields either as a comma delimited list or a mongoose style fields object and converts them into a sequelize compatible array

Kind: global function

Param Type Description
fields Object | string Fields that should be returned when running the query

_QUERY(options, cb)

Convenience method for .findAll sequelize method

Kind: global function

Param Type Default Description
options Object Options for the SQL query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.population] Object | string this.population An object containing an include property which is an array of table associations for a given sequelize model or just the array of associations (see sequelize documentation for proper configuration)
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for query

_STREAM(options, cb)

Convenience method for returning a stream of sql data. Since sequelize does not expose a cursor or stream method this is an implementation of a cursor on top of a normal SQL query

Kind: global function

Param Type Default Description
options Object Options for the SQL query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.population] Object | string this.population An object containing an include property which is an array of table associations for a given sequelize model or just the array of associations (see sequelize documentation for proper configuration)
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for stream

_QUERY_WITH_PAGINATION(options, cb)

Convenience method for .findAll SQL method with built in pagination of data

Kind: global function

Param Type Default Description
options Object Options for the SQL query
[options.query] Object {} The query that should be used for the database search
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.pagelength] number this.pagelength Defines the max length of each sub-set of data
[options.population] Object | string this.population An object containing an include property which is an array of table associations for a given sequelize model or just the array of associations (see sequelize documentation for proper configuration)
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
cb function Callback function for query

_SEARCH(options, cb)

Convenience method for .findAll SQL method with built in query builder functionality

Kind: global function

Param Type Default Description
options Object Options for the SQL query
[options.query] Object | string The query that should be used for the database search. If this value is a string it will be treated as a delimited list of values to use in query
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.limit] number this.limit Limits the total returned documents for query will default to the this.limit value if not defined
[options.pagelength] number this.pagelength Defines the max length of each sub-set of data
[options.population] Object | string this.population An object containing an include property which is an array of table associations for a given sequelize model or just the array of associations (see sequelize documentation for proper configuration)
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.skip] number The number of documents to offset in query
[options.search] Array.<string> this.searchfields Used in building the query. A separate $or statement is appended into query array for each search field specified ie. ['a','b'] => { $or: [{a: ..., b ...}] }
[options.delimeter] string "&quot;
[options.docid] string "this.docid" When using options.values this specifies the name of the field that should be matched
[options.values] string A comma separated list of values to be queried against docid or "_id" if docid is not specified
options.paginate Boolean If true documents will be returned in a paginated format
cb function Callback function for query

_LOAD(options, cb)

Convenience method for .findOne sequelize methods

Kind: global function

Param Type Default Description
options Object Configurable options for mongo query
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
[options.sort] string "this.sort" Sorting criteria for query will default to the this.sort value if not defined
[options.population] Object | string this.population An object containing an include property which is an array of table associations for a given sequelize model or just the array of associations (see sequelize documentation for proper configuration)
[options.fields] Object this.fields The fields that should be returned in query will default to the this.fields value if not defined
[options.docid] string "&quot;id&quot;" A field that should be queried will default to "id"
options.query Object | string | number If value is an object query will be set to the value otherwise a query will be built based on options.docid and any other value provided in options.query
cb function Callback function for load

_UPDATE(options, cb)

Convenience method for .update SQL method

Kind: global function

Param Type Default Description
options Object Configurable options for SQL update
options.isPatch Boolean If true the update will be treated as a patch instead of a full document update
options.updatedoc Object Either specific fields to update in the case of a patch otherwise the entire updatedated document
options.id string The SQL id of the document that should be updated
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.track_changes] Boolean If false changes will not be tracked
[options.ensure_changes] Boolean If true changeset generation and saving is blocking and errors will cause entire operation to fail
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
cb function Callback function for update

_UPDATED(options, cb)

Convenience method for .update + .findOne sequelize method (returns updated document instead of normal number updated status)

Kind: global function

Param Type Default Description
options Object Configurable options for SQL update
options.isPatch Boolean If true the update will be treated as a patch instead of a full document update
options.updatedoc Object Either specific fields to update in the case of a patch otherwise the entire updated document
options.id string The SQL id of the document that should be updated
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.track_changes] Boolean If false changes will not be tracked
[options.ensure_changes] Boolean If true changeset generation and saving is blocking and errors will cause entire operation to fail
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
cb function Callback function for update

_UPDATE_ALL(options, cb)

Convenience method for .update for multiple document updates

Kind: global function

Param Type Default Description
options Object Configurable options for SQL update with no limit
[options.model] Object this.model The mongoose model for query will default to the this.model value if not defined
options.query Object Query that should be used in update
[options.updatequery] Object Alias for options.query if options.query is set this option is ignored
options.updateattributes Object A SQL update formatted object
[options.updatedoc] Object Object specifying fields to update with new values this object will be formatted as a patch update. If options.updateattributes is set this option is ignored
cb function Callback function for update all

_CREATE(options, cb)

Convenience method for .create sequelize method

Kind: global function

Param Type Default Description
options Object Configurable options for SQL create
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
[options.newdoc] Object | Array.<Object> options The document that should be created. If newdoc option is not passed it is assumed that the entire options object is the document. A bulk create will be done if newdoc is an array and bulk_create option is true
options.bulk_create Boolean If true and options.newdoc is an array each index will be treated as an individual document and be bulk inserted (WARNING: Due to limitations in MySQL and other SQL variants bulk creates can't assign auto-incremented ids please use accordingly)
[options.skip_xss] Boolean If true xss character escaping will be skipped and xss whitelist is ignored
[options.html_xss] Boolean If true xss npm module will be used for character escaping
[options.xss_whitelist] Object this.xss_whitelist XSS white-list configuration for xss npm module
cb function Callback function for create

_DELETE(options, cb)

Convenience method for .destroy sequelize method

Kind: global function

Param Type Default Description
options Object Configurable options for SQL delete
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
options.deleteid string The SQL id of the document that should be removed
options.id string If options.deleteid is provided this value is ignored - alias for options.deleteid
options.force Boolean If true document will always be fully deleted (if paranoid option is set on model this option will override)
cb function Callback function for delete

_DELETED(options, cb)

Convenience method for .destroy sequelize method but returns the deleted document

Kind: global function

Param Type Default Description
options Object Configurable options for SQL delete
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
options.deleteid string The SQL id of the document that should be removed
options.id string If options.deleteid is provided this value is ignored - alias for options.deleteid
cb function Callback function for delete

_RAW(options, cb)

Convenience method for .query sequelize method that allows for raw SQL queries

Kind: global function

Param Type Default Description
options Object Configurable options for raw SQL query
[options.model] Object this.model The sequelize model for query will default to the this.model value if not defined
options.query string Raw query for SQL
options.raw_query string Alias for options.query. If options.query is set this option is ignored
options.raw string Alias for options.query. If options.query or options.raw_query is set this option is ignored
options.format_result Boolean | Object If false result will not be formatted. If a sequelize query type object those rules will be used in formatting. If not false and not a format object the query type will be inferred from the raw query and formatting rules will be applied
cb function Callback function for raw query

defaultSuccess(data) ⇒ *

A default on success function for each iteration of cursor

Kind: global function
Returns: * - Simply returns whatever data is passed as data arugment

Param Type Description
data * Generally a single document be pushed by stream but can be any data type or a Buffer if cursor is not instantiated in objectMode

defaultError(e) ⇒ Object

A default on error function for each iteration of cursor

Kind: global function
Returns: Object - Returns a rejected Promise

Param Type Description
e Object An instance of Error