Database

Introduced in 3.0.0

Stability: 2 - Stable

const Database = require('kado/lib/Database')

This library manages Database connections that are stored through instances registered to this library.

Class: Database

Database extends Connect see Connect for more engine management and more.

static Database.queryOptions(config, profiler)

static Database.getInstance()

Database.constructor()

Database.queryOptions(config, profiler)

Database.connect(name)

Note: when no name is provided all connections will be executed.

Database.close(name)

Note: when no name is provided all connections will be closed.

Class: DatabaseEngine

DatabaseEngine extends ConnectEngine see ConnectEngine for more engine management and more.

DatabaseEngine.connect()

Must be extended and used to connect to underlying database.

DatabaseEngine.close()

By default will try and call engine.close() and then call ConnectEngine.resetEngine(). Which should be sufficient for most underlays.

Class: DatabaseMySQL

DatabaseMySQL extends DatabaseEngine extends ConnectEngine and implements a relationship with the JavaScript mysql2 driver available on NPM and Github.

See the mysql2 package

To use this engine it should be required at application startup. Example:

const app = require('kado').getInstance()
const MySQL = require('kado/lib/Database').MySQL
const mysqlConfig = { host: 'localhost', user: 'test', database: 'test' }
app.database.addEngine('mysql', new MySQL(mysqlConfig))

DatabaseMySQL.constructor(options)

The currently supported options are: