Skip to content

dialect

Dialect

Abstract class that each database vendor/driver should extend from

Kind: global class

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

Abstract constructor that sets each passed parameter on the current instance as a property. Extending classes should override the constructor using the same parameters since Manager internally invokes the constructor.

ParamTypeDescription
privtypedefs.SQLERPrivateOptionsThe private configuration options
connConftypedefs.SQLERConnectionOptionsThe individual connection configuration for the given dialect that was passed into the originating Manager
[track]typedefs.SQLERTrackA tracking mechanism that can be used to share configuration between dialect implementations
[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)

dialect.state ⇒ typedefs.SQLERState

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

dialect.driver ⇒ *

The driver module used by the Dialect

Kind: instance property of Dialect
Returns: * - The driver module
Access: protected

dialect.init(opts) ⇒ *

Initializes the Dialect implementation and optionally opens any resources that be need to Dialect.exec

Kind: instance method of Dialect
Returns: * - Any truthy value that indicates the initialization was successful (or an error when returning errors instead of throwing them)

ParamTypeDescription
optstypedefs.SQLERInitOptionsThe initialization options

dialect.beginTransaction(txId, opts) ⇒ typedefs.SQLERTransaction

Starts a transaction. A transaction will typically get/open a connection from the pool and will remain open until commit or rollback are called from the return typedefs.SQLERTransaction. Care must be taken not to drain the pool of available connections.

Kind: instance method of Dialect
Returns: typedefs.SQLERTransaction - The transaction that was started

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

dialect.exec(sql, opts, frags, meta, [errorOpts]) ⇒ typedefs.SQLERExecResults

Executes a SQL statement

Kind: instance method of Dialect
Returns: typedefs.SQLERExecResults - The execution results

ParamTypeDescription
sqlStringThe SQL to execute
optstypedefs.SQLERExecOptionsThe execution options
fragsArray.<String>The frament keys within the SQL that will be retained
metatypedefs.SQLERExecMetaThe metadata used to generate the execution
[errorOpts]typedefs.SQLERExecErrorOptions | BooleanThe error options to use

dialect.close() ⇒ Integer

Closes any dialaect resources that may have been opened during Dialect.init

Kind: instance method of Dialect
Returns: Integer - The number of connections that were closed

Released under the MIT License.