Skip to content

index

Classes

MDBDialect

MariaDB + MySQL Dialect implementation for sqler

Functions

sqlSafeName(prefix, metaName, [frags])SqlSafe

Creates a logical key for human readable indentification for SQL calls and a SQL safe hashed name

Typedefs

MDBConnectionDriverOptions : Object

The mariadb (w/MySQL support) module specific options. Both connection and pool will be merged when generating the connection pool.

MDBConnectionOptions : typedefs.SQLERConnectionOptions

MariaDB + MySQL specific extension of the SQLERConnectionOptions from the sqler module.

MDBExecDriverOptions : Object

MariaDB + MySQL specific extension of the SQLERExecOptions from the sqler module. When a property of binds contains an object it will be interpolated for property values on the mariadb module. For example, binds.name = '${SOME_MARIADB_CONSTANT}' will be interpolated as binds.name = mariadb.SOME_MARIADB_CONSTANT.

MDBExecOptions : typedefs.SQLERExecOptions

MariaDB + MySQL specific extension of the SQLERExecOptions from the sqler module. When a property of binds contains an object it will be interpolated for property values on the mariadb module. For example, binds.name = '${SOME_MARIADB_CONSTANT}' will be interpolated as binds.name = mariadb.SOME_MARIADB_CONSTANT.

MDBDialect

MariaDB + MySQL Dialect implementation for sqler

Kind: global class

new MDBDialect(priv, connConf, track, [errorLogger], [logger], [debug])

Constructor

ParamTypeDescription
privtypedefs.SQLERPrivateOptionsThe private configuration options
connConfMDBConnectionOptionsThe individual SQL connection configuration for the given dialect that was passed into the originating Manager
tracktypedefs.SQLERTrackContainer for sharing data between Dialect instances.
[errorLogger]functionA function that takes one or more arguments and logs the results as an error (similar to console.error)
[logger]functionA function that takes one or more arguments and logs the results (similar to console.log)
[debug]BooleanA flag that indicates the dialect should be run in debug mode (if supported)

mdbDialect.state ⇒ typedefs.SQLERState

Kind: instance property of MDBDialect
Returns: typedefs.SQLERState - The state

mdbDialect.driver ⇒ DBDriver

Kind: instance property of MDBDialect
Returns: DBDriver - The MariaDB/MySQL driver module
Access: protected

mdbDialect.init(opts) ⇒ Promise.<Object>

Initializes MDBDialect by creating the connection pool

Kind: instance method of MDBDialect
Returns: Promise.<Object> - The MariaDB/MySQL connection pool

ParamTypeDescription
optstypedefs.SQLERInitOptionsThe options described by the sqler module

mdbDialect.beginTransaction(txId, opts) ⇒ Promise.<typedefs.SQLERTransaction>

Begins a transaction by opening a connection from the pool

Kind: instance method of MDBDialect
Returns: Promise.<typedefs.SQLERTransaction> - The transaction that was started

ParamTypeDescription
txIdStringThe internally generated transaction identifier
optstypedefs.SQLERTransactionOptionsThe transaction options passed in via the public API

mdbDialect.exec(sql, opts, frags, meta, [errorOpts]) ⇒ Promise.<typedefs.SQLERExecResults>

Executes a SQL statement

Kind: instance method of MDBDialect
Returns: Promise.<typedefs.SQLERExecResults> - The execution results

ParamTypeDescription
sqlStringthe SQL to execute
optsMDBExecOptionsThe execution options
fragsArray.<String>the frament keys within the SQL that will be retained
metatypedefs.SQLERExecMetaThe SQL execution metadata
[errorOpts]typedefs.SQLERExecErrorOptions | BooleanThe error options to use

mdbDialect.close() ⇒ Integer

Closes the MariaDB/MySQL connection pool

Kind: instance method of MDBDialect
Returns: Integer - The number of connections closed

sqlSafeName(prefix, metaName, [frags]) ⇒ SqlSafe

Creates a logical key for human readable indentification for SQL calls and a SQL safe hashed name

Kind: global function
Returns: SqlSafe - SQL safe names

ParamTypeDescription
prefixStringPrefix to use in the SQL name
metaNameStringPrepared statement meta name
[frags]Array.<String> | nullSQL fragment substitutions being used

MDBConnectionDriverOptions : Object

The mariadb (w/MySQL support) module specific options. Both connection and pool will be merged when generating the connection pool.

Kind: global typedef
Properties

NameTypeDescription
[connection]ObjectAn object that will contain properties/values that will be used to construct the MariaDB + MySQL connection (e.g. { database: 'mydb', timezone: '-0700' }). See the mariadb module documentation for a full listing of available connection options. When a property value is a string surrounded by ${}, it will be assumed to be a property that resides on either the SQLERPrivateOptions passed into the Manager constructor or a property on the MDBConnectionOptions itself (in that order of precedence). For example, connOpts.host = '127.0.0.1' and driverOptions.connection.host = '${host}' would be interpolated into driverOptions.connection.host = '127.0.0.1'. In contrast to privOpts.username = 'someUsername' and driverOptions.connection.user = '${username}'would be interpolated intodriverOptions.connection.user = 'someUsername'. Interpoaltions can also contain more than one reference. For example, driverOptions.connection.someProp = '${protocol}😒{host}'for privOpts = { protocol: 'TCP', host: 'example.com' }would becomesomeProp='TCP:example.com'`.
[pool]ObjectThe pool conf options that will be passed into mariadb.createPool(conf). See the mariadb module for a full listing of avialable connection pooling options. Using any of the generic pool.someOption will override the conf options set on driverOptions.pool (e.g. pool.max = 10 would override driverOptions.pool.connectionLimit = 20). When a value is a string surrounded by ${}, it will be assumed to be a constant property that resides on the mariadb module and will be interpolated accordingly. For example driverOptions.pool.someProp = '${SOME_MARIADB_CONSTANT}' will be interpolated as pool.someProp = mariadb.SOME_MARIADB_CONSTANT.

MDBConnectionOptions : typedefs.SQLERConnectionOptions

MariaDB + MySQL specific extension of the SQLERConnectionOptions from the sqler module.

Kind: global typedef
Properties

NameTypeDescription
driverOptionsMDBConnectionDriverOptionsThe mariadb (w/MySQL support) module specific options. Both connection and pool will be merged when generating the connection pool.

MDBExecDriverOptions : Object

MariaDB + MySQL specific extension of the SQLERExecOptions from the sqler module. When a property of binds contains an object it will be interpolated for property values on the mariadb module. For example, binds.name = '${SOME_MARIADB_CONSTANT}' will be interpolated as binds.name = mariadb.SOME_MARIADB_CONSTANT.

Kind: global typedef
Properties

NameTypeDefaultDescription
[preparedStatementDatabase]StringThe database name to use when generating prepared statements for the given execution. Since prepared statements are scoped only for a given connection and a temporary stored procedure is used to execute prepared statements, preparedStatementDatabase is required when execOpts.prepareStatement = true.
[exec]ObjectThe options passed into execution/query functions provided by the mariadb module performed during Manager.exec. When a value is a string surrounded by ${}, it will be assumed to be a constant property that resides on the mariadb module and will be interpolated accordingly. For example driverOptions.exec.someDriverProp = '${SOME_MARIADB_CONSTANT}' will be interpolated as driverOptions.exec.someDriverProp = mariadb.SOME_MARIADB_CONSTANT.
[exec.namedPlaceholders]BooleantrueTruthy to use named parameters in MariaDB/MySQL or falsy to convert the named parameters into a positional array of bind values.

MDBExecOptions : typedefs.SQLERExecOptions

MariaDB + MySQL specific extension of the SQLERExecOptions from the sqler module. When a property of binds contains an object it will be interpolated for property values on the mariadb module. For example, binds.name = '${SOME_MARIADB_CONSTANT}' will be interpolated as binds.name = mariadb.SOME_MARIADB_CONSTANT.

Kind: global typedef
Properties

NameTypeDescription
[driverOptions]MDBExecDriverOptionsThe mariadb module specific options.

Released under the MIT License.