dialect
Dialect
Abstract class that each database vendor/driver should extend from
Kind: global class
- Dialect
- new Dialect(priv, connConf, [track], [errorLogger], [logger], [debug])
- .state ⇒
typedefs.SQLERState - .driver ⇒
* - .init(opts) ⇒
* - .beginTransaction(txId, opts) ⇒
typedefs.SQLERTransaction - .exec(sql, opts, frags, meta, [errorOpts]) ⇒
typedefs.SQLERExecResults - .close() ⇒
Integer
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.
| Param | Type | Description |
|---|---|---|
| priv | typedefs.SQLERPrivateOptions | The private configuration options |
| connConf | typedefs.SQLERConnectionOptions | The individual connection configuration for the given dialect that was passed into the originating Manager |
| [track] | typedefs.SQLERTrack | A tracking mechanism that can be used to share configuration between dialect implementations |
| [errorLogger] | function | A function that takes one or more arguments and logs the results as an error (similar to console.error) |
| [logger] | function | A function that takes one or more arguments and logs the results (similar to console.log) |
| [debug] | Boolean | A 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)
| Param | Type | Description |
|---|---|---|
| opts | typedefs.SQLERInitOptions | The 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
| Param | Type | Description |
|---|---|---|
| txId | String | The internally generated transaction identifier |
| opts | typedefs.SQLERTransactionOptions | The 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
| Param | Type | Description |
|---|---|---|
| sql | String | The SQL to execute |
| opts | typedefs.SQLERExecOptions | The execution options |
| frags | Array.<String> | The frament keys within the SQL that will be retained |
| meta | typedefs.SQLERExecMeta | The metadata used to generate the execution |
| [errorOpts] | typedefs.SQLERExecErrorOptions | Boolean | The 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