@absolunet/ioc2.1.0

View on GitHub

Driver

Abstract database connector driver.

Members

(static) dependencies :Array.<string>

Source:
Class dependencies: ['config', 'db.resolver', 'file'].

(abstract) client :string

Source:
Client to be used, such as "mysql", "sqlite3", etc.

migrationsTable :string

Source:
The migration table name.

Methods

getConnection(nameopt)

Source:
Get Knex connection.
Parameters:
Name Type Attributes Default Description
name string <optional>
"default" The connection name.
Returns:
A Knex connection instance.
Type
Knex

getDefaultConnection()

Source:
Get default Knex connection.
Returns:
A Knex connection instance.
Type
Knex

setConnection(name, connection)

Source:
Set Knex connection with name.
Parameters:
Name Type Description
name string The connection name.
connection Knex The Knex connection instance.
Returns:
The current driver instance.
Type
translation.services.Translator.drivers.Driver

setDefaultConnection(connection)

Source:
Set default Knex connection instance.
Parameters:
Name Type Description
connection Knex The Knex connection instance.
Returns:
The current driver instance.
Type
translation.services.Translator.drivers.Driver

hasConnection(name)

Source:
Check if connection exists by name.
Parameters:
Name Type Description
name string The connection name.
Returns:
Indicates that the connection exists.
Type
boolean

getOrCreateConnection(name, config)

Source:
Get connection if it exists, otherwise create a new connection and returns it.
Parameters:
Name Type Description
name string The connection name.
config object The connection configuration.
Returns:
A Knex connection instance.
Type
Knex

createConnection(name, config)

Source:
Create new connection and store it by name.
Parameters:
Name Type Description
name string The connection name.
config object The connection configuration.
Returns:
A Knex connection instance.
Type
Knex

makeConnection(config)

Source:
Make new Knex connection.
Parameters:
Name Type Description
config object The connection configuration.
Returns:
A Knex instance.
Type
Knex

mapConfig(config)

Source:
Map configuration from the driver and given configuration into a Knex configuratioon model.
Parameters:
Name Type Description
config object The connection configuration.
Returns:
The full Knex connection configuration.
Type
object

(async) clean(connectionopt, optionsopt)

Source:
See:
  • dropAll()
Clean the database of existing data. Keeps the tables.
Parameters:
Name Type Attributes Description
connection Knex <optional>
The Knex connection instance.
options object <optional>
The knex-clean options.
Returns:
The async process promise.
Type
Promise

(async) dropAll(connectionopt, optionsopt)

Source:
Drop all tables from the database.
Parameters:
Name Type Attributes Description
connection Knex <optional>
The Knex connection instance.
options object <optional>
The knex-clean options.
Returns:
The async process promise.
Type
Promise

(async) migrationStatus(connection)

Source:
Get migration status.
Parameters:
Name Type Description
connection Knex The Knex connection instance.
Returns:
The migration status.
Type
Promise.<Array.<{name: string, ran: boolean}>>