Class: SQL_ADAPTER

SQL_ADAPTER

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

Constructor

new SQL_ADAPTER(options)

Constructor for SQL_Adapter

Parameters:
Name Type Description
options Object

Configurable options for the SQL adapter

Properties
Name Type Attributes Default Description
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

db_connetion.db_name string <optional>

Name of the database (only used if instantiating a new Sequelize instance)

db_connetion.db_user string <optional>

Username for the database (only used if instantiating a new Sequelize instance)

db_connetion.db_password string <optional>

Password for the database (only used if instantiating a new Sequelize instance)

db_connetion.db_options string <optional>

Options for connection to the database ie. port, hostname (only used if instantiating a new Sequelize instance)

docid string <optional>
"id"

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

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

sort Object | string <optional>
"createdat DESC"

Specifies default sort logic for .query and .search queries

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 | Array.<Object> <optional>
[]

Optional population configuration for documents returned in .load and .search queries (see sequelize include for proper formatting)

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

raw(options, cb) → {Object}

Raw query method for adapter see _RAW for more details

Parameters:
Name Type Default Description
options Object

Configurable options for raw query

cb function 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

sync(optionsopt, cbopt) → {Object}

Sync defined sequelize models with SQL db

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

Configurable options for sequelize sync method

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