typedefs
Members
- MOD_KEY
Module key used for the object namespace on errors and logging
- NS
Namespace on a
Managerwhere SQL functions will be added- CRUD_TYPES
Valid CRUD operation names
- POS_BINDS_REGEXP
RegExpfor capturing named bind parameter names within SQL- FUNC_NAME_DIR_REGEXP
RegExpfor removing invalid chars from prepared function directory names- FUNC_NAME_FILE_REGEXP
RegExpfor removing invalid chars from prepared function file names- FUNC_NAME_SEPARATOR
Separator for prepared function names (also used as the dir/filename replacement)
- EVENT_STREAM_STATEMENT_PREPARED
Event name that is emitted when a stream has prepared a statement. Listeners will receive a single argument that contains the SQLERExecResults.
- EVENT_STREAM_STATEMENT_UPREPARED
Event name that is emitted when a stream has unprepared a statement. Listeners will receive a single argument that contains the SQLERExecResults.
- EVENT_STREAM_BATCH
Event name that is emitted when a stream has finished execution for a series of reads or writes included in a batch. Listeners will receive a single
Object[]argument that contains the raw results returned by each of the dialect SQL read or write executions.- EVENT_STREAM_COMMIT
Event name that is emitted when a stream has committed a transaction. Listeners will receive a single
Stringargument that contains the transaction ID returned by each of the dialect SQL read or write executions.- EVENT_STREAM_ROLLBACK
Event name that is emitted when a stream has rolled back a transaction. Listeners will receive a single
Stringargument that contains the transaction ID returned by each of the dialect SQL read or write executions.- EVENT_STREAM_RELEASE
Event name that is emitted when a stream has released or closed the connection used by the read or write stream (managed by individual dialect implementations). Listeners will not receive any arguments.
Objects
- typedefs :
object Global type definitions used by
sqler
MOD_KEY
Module key used for the object namespace on errors and logging
Kind: global variable
NS
Namespace on a Manager where SQL functions will be added
Kind: global variable
CRUD_TYPES
Valid CRUD operation names
Kind: global variable
POS_BINDS_REGEXP
RegExp for capturing named bind parameter names within SQL
Kind: global variable
FUNC_NAME_DIR_REGEXP
RegExp for removing invalid chars from prepared function directory names
Kind: global variable
FUNC_NAME_FILE_REGEXP
RegExp for removing invalid chars from prepared function file names
Kind: global variable
FUNC_NAME_SEPARATOR
Separator for prepared function names (also used as the dir/filename replacement)
Kind: global variable
EVENT_STREAM_STATEMENT_PREPARED
Event name that is emitted when a stream has prepared a statement. Listeners will receive a single argument that contains the SQLERExecResults.
Kind: global variable
EVENT_STREAM_STATEMENT_UPREPARED
Event name that is emitted when a stream has unprepared a statement. Listeners will receive a single argument that contains the SQLERExecResults.
Kind: global variable
EVENT_STREAM_BATCH
Event name that is emitted when a stream has finished execution for a series of reads or writes included in a batch. Listeners will receive a single Object[] argument that contains the raw results returned by each of the dialect SQL read or write executions.
Kind: global variable
EVENT_STREAM_COMMIT
Event name that is emitted when a stream has committed a transaction. Listeners will receive a single String argument that contains the transaction ID returned by each of the dialect SQL read or write executions.
Kind: global variable
EVENT_STREAM_ROLLBACK
Event name that is emitted when a stream has rolled back a transaction. Listeners will receive a single String argument that contains the transaction ID returned by each of the dialect SQL read or write executions.
Kind: global variable
EVENT_STREAM_RELEASE
Event name that is emitted when a stream has released or closed the connection used by the read or write stream (managed by individual dialect implementations). Listeners will not receive any arguments.
Kind: global variable
typedefs : object
Global type definitions used by sqler
Kind: global namespace
- typedefs :
object- .SQLERCache :
Object - .SQLERPrivateOptions :
Object - .SQLERConfigurationOptions :
Object - .SQLERUniversalOptions :
Object - .SQLERConnectionOptions :
Object - .SQLERExecOptions :
Object - .SQLERExecMeta :
Object - .SQLERExecErrorOptions :
Object - .SQLERPreparedFunction ⇒
SQLERExecResults - .SQLERExecResults :
Object - .SQLERTransactionCommit :
function - .SQLERTransactionRollback :
function - .SQLERTransaction :
Object - .SQLERTransactionOptions :
Object - .SQLEROperationOptions :
Object - .SQLEROperationResults :
Object - .SQLERInitOptions :
Object - .SQLERState :
Object - .SQLERInterpolateValidationFunction ⇒
Boolean - .SQLERInterpolateFunction ⇒
Object - .SQLERPositionalBindsFunction ⇒
String - .SQLERBindExpansionFunction ⇒
String - .SQLERStreamReader ⇒
* - .SQLERStreamWritter ⇒
* - .SQLERStreamReadableProcessor ⇒
Stream.Readable - .SQLERStreamWritable ⇒
Stream.Writable - .SQLERTrack :
Object
- .SQLERCache :
typedefs.SQLERCache : Object
The cache client responsible for regulating the frequency in which a SQL file is read by a Manager.
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| start | function | An async function() that starts caching. This could be a noop or could start any background processing and/or capture of cached keys (depending on the type of implementation). |
| stop | function | An async function() that stops caching. This could be a noop or could stop any background processing and/or capture of cached keys (depending on the type of implementation). |
| get | function | An async function(key) that gets a corresponding SQL statement from cache using the specified key to uniquily identify the SQL source (typically generated by a Manager). The returned object will contain the following values when present (otherwise, returns null): - item - The cached SQL statement - stored - The timestamp indicating the time when the SQL statement was stored in cache - ttl - The timestamp indicating the remaining time left before the SQL statement will be removed from cache |
| set | function | An async function(key, sql, ttlOverride) that sets a SQL statement in cache, overriding the time-to-live_ (in milliseconds) that may have been set by a Manager. |
| drop | function | An async function(key) that removes the specified key from cache |
Example
// cache options can be different depending on the needs of the implementing cache
const cacheOpts = {
"expiresIn": 60000
};
// simple interval cache for illustration purposes
const bank = { store: {}, handles: {} };
const cache = {
start: async () => {
let cached, calTtl;
for (let key in bank.handles) {
clearInterval(bank.handles[key]);
cached = bank.store.hasOwnProperty(key) ? bank.store[key] : null;
calTtl = !cached|| isNaN(cached.ttl) ? cacheOpts.expiresIn : cached.ttl;
bank.handles[key] = setInterval(() => delete bank.store[key], calTtl);
}
},
stop: async () => {
for (let key in bank.handles) {
clearInterval(bank.handles[key]);
}
},
get: async key => {
const cached = bank.store.hasOwnProperty(key) ? bank.store[key] : null;
if (cached) cached.ttl = Date.now() - cached.stored;
return Promise.resolve(cached ? JSON.parse(JSON.stringify(cached)) : cached);
},
set: async (key, val, ttl) => {
if (bank.handles[key]) clearInterval(bank.handles[key]);
const calTtl = !ttl || isNaN(ttl) ? cacheOpts.expiresIn : ttl;
bank.store[key] = { item: val, stored: Date.now(), ttl: calTtl };
bank.handles[key] = setInterval(sql => delete bank.store[key], calTtl);
return Promise.resolve();
},
drop: async () => {
if (bank.handles[key]) {
clearInterval(bank.handles[key]);
delete bank.handles[key];
}
if (bank.store[key]) delete bank.store[key];
}
};
// manager configuration
const conf = {
// other required conf options here
"db": {
"connections": [
{
// other required connection conf options here
}
]
}
};
const mgr = new Manager(conf, cache);
await mgr.init();
// use the manager to execute SQL files that will
// be refreshed/re-read every 60 seconds
// can also set the cache after Manager.init()
const setCacheResults = await mgr.setCache(cache);typedefs.SQLERPrivateOptions : Object
Private options for global Manager use
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| [username] | String | The username to connect to the database |
| [password] | String | The password to connect to the database |
| [host] | String | The host to connect to for the database |
| [port] | String | The port to connect to for the database (when not included in the host) |
| [protocol] | String | The protocol to use when connecting to the database |
| [privatePath] | String | The private path set by an originating Manager constructor (when not already set) that may be used by an implementing Dialect for private data use (e.g. TNS files, etc.) |
typedefs.SQLERConfigurationOptions : Object
Configuration options for Manager use
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| [mainPath] | String | Root directory starting point to look for SQL files (defaults to require.main path or process.cwd()) |
| [privatePath] | String | Current working directory where generated files will be located (if any, defaults to process.cwd()) |
| [debug] | Boolean | Truthy to turn on debugging |
| univ | SQLERUniversalOptions | The SQLERUniversalOptions |
| db | Object | The public facing database configuration |
| db.dialects | Object | An object that contains Dialect implementation details where each property name matches a dialect name and the value contains either the module class or a string that points to a Dialect implementation for the given dialect (e.g. { dialects: { 'oracle': 'sqler-oracle' } }). When using a directory path the dialect path will be prefixed with process.cwd() before loading. |
| db.connections | Array.<SQLERConnectionOptions> | The connections options that will be used. |
typedefs.SQLERUniversalOptions : Object
The universal configuration that, for security and sharing purposes, remains external to an application
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| db | Object | The database options that contain private sensitive configuration. Each property should correspond to a SQLERPrivateOptions instance and the property name should be linked to a SQLERConnectionOptions id within conf.db.connections. Each SQLERPrivateOptions instance will be used to connect to the underlying database (e.g. { db: myConnId: { host: "someDbhost.example.com", username: "someUser", password: "somePass" } }) |
typedefs.SQLERConnectionOptions : Object
Options for connections used by Manager
Kind: static typedef of typedefs
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| id | String | Identifies the connection within a SQLERPrivateOptions | |
| dialect | String | The database dialect (e.g. mysql, mssql, oracle, etc.) | |
| name | String | The name given to the database used as the property name on the Manager to access generated SQL functions (e.g. name = 'example' would result in a SQL function connection container manager.db.example). The name will also be used as the cwd relative directory used when no dir is defined | |
| [dir] | String | name | The alternative dir where *.sql files will be found relative to mainPath passed into a Manager constructor. The directory path will be used as the basis for generating SQL statements from discovered SQL files. Each will be made accessible in the manager by name followed by an object for each name separated by period(s) within the file name with the last entry as the executable SQLERPreparedFunction. For example, a connection named "conn1" and a SQL file named "user.team.details.sql" will be accessible within the manager as "mgr.db.conn1.user.team.details()". But when dir is set to "myDir" the SQL files will be loaded from the "myDir" directory (relative to mainPath) instead of the default directory that matches the connection name "conn1". |
| [version] | Float | A version that can be used for version substitutions within an SQL statement | |
| [service] | String | The service name defined by the underlying database (may be required depending on the implementing Dialect | |
| [binds] | Object | The global object that contains bind variable values that will be included in all SQL calls made under the connection for parameter binds if not overridden by individual "binds" passed into the SQLERPreparedFunction | |
| [substitutes] | Object | Key/value pairs that define global/static substitutions that will be made in prepared statements by replacing occurances of keys with corresponding values | |
| [host] | String | The database host override for a value specified in SQLERPrivateOptions | |
| [port] | String | The database port override for a value specified in SQLERPrivateOptions | |
| [protocol] | String | The database protocol override for a value specified in SQLERPrivateOptions | |
| [dateFormatter] | function | Boolean | A function(date) that will be used to format bound dates into string values for SQLERPreparedFunction calls. Set to a truthy value to perform date.toISOString(). Gets overridden by the same option set on SQLERExecOptions. | |
| [driverOptions] | Object | Options passed directly into the Dialect driver | |
| [log] | Boolean | Array.<String> | When logging is turned on for a given Manager, the specified tags will prefix the log output. Explicity set to false to disable connection log level logging even if it is turned on via the Manager. | |
| [logError] | Boolean | Array.<String> | When logging is turned on for a given Manager, the specified tags will prefix the error log output. Explicity set to false to disable connection error level logging even if it is turned on via the Manager. | |
| [pool] | Object | The connection pool options (overrides any driverOptions that may pertain the pool) | |
| [pool.max] | Number | The maximum number of connections in the pool. When pool.min and pool.max are the same, pool.increment should typically be set to zero. (overrides any driverOptions that may pertain the pool max) | |
| [pool.min] | Number | The minumum number of connections in the pool. When pool.min and pool.max are the same, pool.increment should typically be set to zero. (overrides any driverOptions that may pertain the pool min) | |
| [pool.idle] | Number | The maximum time, in milliseconds, that a connection can be idle before being released (overrides any driverOptions that may pertain the pool idle) | |
| [pool.increment] | Number | The number of connections that are opened whenever a connection request exceeds the number of currently open connections. When pool.min and pool.max are the same, pool.increment should typically be set to zero. (overrides any driverOptions that may pertain the pool increment) | |
| [pool.timeout] | Number | The number of milliseconds that a connection request should wait in the queue before the request is terminated (overrides any driverOptions that may pertain the pool timeout) | |
| [pool.alias] | String | When supported, the alias of this pool in the connection pool cache (overrides any driverOptions that may pertain the pool alias) |
typedefs.SQLERExecOptions : Object
Options that are passed to generated SQLERPreparedFunction. NOTE: Either transaction.commit or trnasaction.rollback must be invoked when autoCommit is falsy and a valid transactionId is supplied to ensue underlying connections are completed and closed.
Kind: static typedef of typedefs
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [name] | String | A name to assign to the execution. | |
| [type] | String | The type of CRUD operation that is being executed (i.e. CREATE, READ, UPDATE, DELETE). Mandatory only when the generated/prepared SQL function was generated from a SQL file that was not prefixed with a valid CRUD type. | |
| [stream] | Number | A value stream >= 0, indicates that the execution will be streamed (ideal for large reads/writes). The resulting rows will contain either a stream.Readable[] or a stream.Writable[] (depending upon the type) instead of the default Object[] rows. When supported by the dialect, streams will be batched using the indicated stream count as the batch size (a value of 0 is the same as a value of 1). | |
| [binds] | Object | {} | The key/value pair of binding parameters that will be bound in the SQL statement. |
| [autoCommit] | Boolean | true | Truthy to perform a commits the transaction at the end of the prepared function execution. NOTE: When falsy the underlying connection will remain open until the returned SQLERExecResults commit or rollback is called. See AutoCommit for more details. |
| [transactionId] | String | A transaction ID returned from a prior call to const tx = await manager.db.myConnectionName.beginTransaction(); options.transactionId = tx.id that will be used when executing the SQLERPreparedFunction. The generated transactionId helps to isolate executions to a single open connection in order to prevent inadvertently making changes on database connections used by other transactions that may also be in progress. The transactionId is ignored when there is no transaction in progress with the specified transactionId. | |
| [prepareStatement] | Boolean | Truthy to generate or use an existing prepared statement for the SQL being executed via the SQLERPreparedFunction. Prepared statements may help optimize SQL that is executed many times across the same connection with similar or different bind values. Care must be taken not to drain the connection pool since the connection remains open until the SQL executions have completed and unprepare has been called on the SQLERExecResults. returned from the SQLERPreparedFunction call. | |
| [dateFormatter] | function | Boolean | A function(date) that will be used to format bound dates into string values for SQLERPreparedFunction calls. Set to a truthy value to perform date.toISOString(). Overrides the same option set on SQLERConnectionOptions. | |
| numOfPreparedFuncs | Number | The total number of SQLERPreparedFunction(s) that reside within the manager | |
| [driverOptions] | Object | Options that may override the SQLERConnectionOptions for driverOptions that may be passed into the Manager constructor |
typedefs.SQLERExecMeta : Object
Internally generated metadata that is passed into Dialect.exec by a Manager for determining SQL sources.
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| name | String | The composed name given to a given SQL file |
| path | String | The path to the SQL file |
typedefs.SQLERExecErrorOptions : Object
Options for handling any errors that occur during execution.
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| [handler] | function | A function(error) that will handle any errors thrown. The errors should contain a sqler property containing |
| [includeBindValues] | Boolean | Truthy to include the bind parameter values error.sqler. |
| [returnErrors] | Boolean | Truthy to return any errors that may occur. Otherwise, throw any errors that may occur. |
typedefs.SQLERPreparedFunction ⇒ SQLERExecResults
Prepared functions are auto-generated async functions that execute an SQL statement from an SQL file source.
Kind: static typedef of typedefs
Returns: SQLERExecResults - The execution results
| Param | Type | Description |
|---|---|---|
| [opts] | SQLERExecOptions | The SQL execution options |
| [frags] | Array.<String> | Consists of any fragment segment names present in the SQL being executed that will be included in the final SQL statement. Any fragments present in the SQL source will be excluded from the final SQL statement when there is no matching fragment name. |
| [errorOpts] | SQLERExecErrorOptions | Boolean | Either the error handling options or a boolean flag indicating that any errors that occur during execution should be returned in the SQLERExecResults rather then being thrown. |
typedefs.SQLERExecResults : Object
Results returned from invoking a SQLERPreparedFunction.
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| [rows] | Array.<Object> | Array.<Stream.Readable> | Array.<Stream.Writable> | The execution array of model objects representing each row or undefined when executing a non-read SQL statement. When streaming the resulting rows will contain either a stream.Readable[] or a stream.Writable[] instead of the default Object[] rows. |
| [unprepare] | function | A no-argument async function that unprepares an outstanding prepared statement. Will not be available when the SQLERPreparedFunction is called when the specified prepareStatement is falsy on the SQLERExecOptions passed into the SQLERPreparedFunction. When a prepared statement is used in conjunction with a SQLERTransaction transactionId on the SQLERExecOptions, unprepare will be implicitly called when transaction.commit or transaction.rollback are called (of course, unprepare can still be explicitly called as well). NOTE: A call to unprepare must be invoked when a prepareStatement is truthy to ensue underlying statements and/or connections are completed and closed. |
| [error] | Error | Any caught error that occurred when a SQLERPreparedFunction was invoked with the errorOpts flag set to a truthy value. |
| raw | Object | The raw results from the execution (driver-specific execution results). |
typedefs.SQLERTransactionCommit : function
Function that commits an outstanding transaction.
Kind: static typedef of typedefs
| Param | Type | Description |
|---|---|---|
| [isRelease] | Boolean | When truthy, releases the connection back to the connection pool after a commit has been performed. It's essential that connections be released back into the connection pool to ensure that there are enough available connections for other independent executions that use the same pool. |
typedefs.SQLERTransactionRollback : function
Function that rolls back an outstanding transaction.
Kind: static typedef of typedefs
| Param | Type | Description |
|---|---|---|
| [isRelease] | Boolean | When truthy, releases the connection back to the connection pool after a rollback has been performed. It's essential that connections be released back into the connection pool to ensure that there are enough available connections for other independent executions that use the same pool. |
typedefs.SQLERTransaction : Object
Transaction that symbolizes a unit of work performed within a Manager connection.
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| id | String | The unique identifier for the transaction. |
| commit | SQLERTransactionCommit | Rolls back the outstanding transaction. |
| rollback | SQLERTransactionRollback | Commits the outstanding transaction. |
| state | Object | The state of the transaction |
| state.committed | Number | True when the transaction has been committed. |
| state.rolledback | Number | True when the transaction has been rolledback. |
| state.pending | Number | The number of pending SQL statements executed within the scope of the given transaction that have not been committed or rolledback. |
| state.isReleased | Boolean | Truthy when the transaction has been released. |
typedefs.SQLERTransactionOptions : Object
Options for a SQLERTransaction that can be passed into a manager.connectionName.beginTransaction(transactionDriverOptions) function.
Kind: static typedef of typedefs
typedefs.SQLEROperationOptions : Object
Options for operational methods on a Manager (e.g. Manager.init, Manager.state, Manager.close, etc.).
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| [connections] | Object | An object that contains connection names as properties. Each optionally containing an object with errorOpts and/or executeInSeries that will override any global options set directly on the SQLEROperationOptions. For example, opts.connections.myConnection.executeInseries would override opts.executeInSeries for the connection named myConnection, but would use opts.executeInSeries for any other connections that ae not overridden. |
| [executeInSeries] | Boolean | Set to truthy to execute the operation in series, otherwise executes operation in parallel. |
| [errorOpts] | SQLERExecErrorOptions | Boolean | Set to truthy to return any errors. Otherise throw any errors as they are encountered. options can also be set instead. |
typedefs.SQLEROperationResults : Object
Results returned from invoking an operational method on a Manager (e.g. Manager.init, Manager.state, Manager.close, etc.).
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| result | Object | An object that contains a property name that matches each connection that was processed (the property value is the number of operations processed per connection). |
| errors | Array.<Error> | Any errors that may have occurred on the operational methods. Should only be populated when SQLEROperationOptions are used with a truthy value set on errorOpts. Each will contain meta properties set by Asynchro. |
typedefs.SQLERInitOptions : Object
Options that are used during initialization
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| numOfPreparedFuncs | Number | The total number of SQLERPreparedFunction(s) registered on the Dialect |
typedefs.SQLERState : Object
The current state of the managed Dialect
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| pending | Number | The number of transactions that are pending commit or roolback plus any prepared statements that are pending unprepare. |
| [connections] | Object | The connection state |
| [connections.count] | Number | The number of connections |
| [connections.inUse] | Number | The number of connections that are in use |
typedefs.SQLERInterpolateValidationFunction ⇒ Boolean
A validation for validating interpolation used by a SQLERInterpolateFunction
Kind: static typedef of typedefs
Returns: Boolean - Flag indicating whether or not to include the interpolated property/value
| Param | Type | Description |
|---|---|---|
| srcPropNames | Array.<String> | Property path(s) to the value being validated (e.g. source.my.path = 123 would equate to a invocation to validator(['my','path'], 123)). |
| srcPropValue | * | The value being validated for interpolation |
typedefs.SQLERInterpolateFunction ⇒ Object
Interpolates values from a source object to a destination object. When a value is a string surrounded by ${}, it will be assumed to be a interpolated property that resides on another property on the source or an interpolated property on the interpolator. For example source.someProp = '${SOME_VALUE}' will be interpreted as dest.someProp = dest.SOME_VALUE when the interpolator is omitted and dest.someProp = interpolator.SOME_VALUE when an interpolator is specified. Typically only used by implementing Dialect constructors within a SQLERTrack.
Kind: static typedef of typedefs
Returns: Object - The passed destination
| Param | Type | Default | Description |
|---|---|---|---|
| dest | Object | The destination where the sources will be set (also the interpolated source when interpolator is omitted). | |
| source | Object | The source of the values to interpolate (e.g. SQLERConnectionOptions, SQLERExecOptions, etc.). | |
| [interpolator] | Object | dest | An alternative source to use for extracting interpolated values from. |
| [validator] | SQLERInterpolateValidationFunction | A validation function for each property/value being interpolated to determine if it will be interolated. | |
| [onlyInterpolated] | Boolean | Truthy to indicate that the only values that will be set from the source/interpolator will be values that have been interpolated. NOTE: Truthy values will not prevent source/interpolator objects from getting set on dest, just non-interpoalted property values will be skipped (i.e. property values that do not contain ${} interpolation designations). |
typedefs.SQLERPositionalBindsFunction ⇒ String
Converts a SQL statement that contains named bind parameters into a SQL statement that contains unnamed/positional bind parameters (using ?). Each bound parameter is pushed to the array in the position that corresponds to the position within the SQL statement.
Kind: static typedef of typedefs
Returns: String - The converted SQL statement
Throws:
ErrorThrown when a bound parameter is not within the orgiginating SQL statement
| Param | Type | Default | Description |
|---|---|---|---|
| sql | String | The SQL statement that contains the bind parameters | |
| bindsObject | Object | An object that contains the bind parameters as property names/values | |
| bindsArray | Array | The array that will be populated with the bind parameters | |
| [placeholder] | String | function | ? | Either a string value that will be used for the postional placeholder or a function(name, index) that returns a value that will be used as the positional placeholder. |
typedefs.SQLERBindExpansionFunction ⇒ String
Expands bind variables that contain an array of values when they appear in the SQL statement. For example, an SQL statement with a section that contains IN (:someParam) and binds of { someParam: [1,2,3] } would become IN (:someParam, :someParam1, :someParam2) with binds of { someParam: 1, someParam1: 2, SomeParam2: 3 }
Kind: static typedef of typedefs
Returns: String - The defragmented SQL
| Param | Type | Description |
|---|---|---|
| sql | String | The SQL to defragement |
| [binds] | Object | An object that contains the SQL parameterized binds that will be used for parameterized array composition |
typedefs.SQLERStreamReader ⇒ *
Processes a read batch of streamed objects for a particular dialect implementation.
Kind: static typedef of typedefs
Returns: * - A value that will be emitted on a readable stream.
| Param | Type | Description |
|---|---|---|
| batch | Array.<Object> | The batch of streamed objects based upon a predefined stream batch size in SQLERExecOptions. |
typedefs.SQLERStreamWritter ⇒ *
Writes a batch of streamed objects for a particular dialect implementation and returns the raw results.
Kind: static typedef of typedefs
Returns: * - The raw batch execution results from the dialect execution and will be emitted on a writable stream.
| Param | Type | Description |
|---|---|---|
| batch | Array.<Object> | The batch of streamed objects based upon a predefined stream batch size in SQLERExecOptions. |
typedefs.SQLERStreamReadableProcessor ⇒ Stream.Readable
Function that internally handles the specified SQLERExecOptions stream batch size and emits a batch event when the batch size threshold has been reached on a specified stream.Readable.
Kind: static typedef of typedefs
Returns: Stream.Readable - The readable stream that was passed
| Param | Type | Description |
|---|---|---|
| opts | SQLERExecOptions | The execution options |
| readStream | Stream.Readable | The readable stream that will produce the SQL results |
| [reader] | SQLERStreamReader | The function that will process the batch read |
typedefs.SQLERStreamWritable ⇒ Stream.Writable
Function that will generate a Stream.Writable that internally handles the specified SQLERExecOptions stream batch size and emits a batch event when the batch size threshold has been reached.
Kind: static typedef of typedefs
Returns: Stream.Writable - The writable stream that will handle the sqler internals
| Param | Type | Description |
|---|---|---|
| opts | SQLERExecOptions | The execution options |
| writter | SQLERStreamWritter | The function that will process the batch write |
typedefs.SQLERTrack : Object
A tracking mechanism that is shared between all Dialect implementations for a given Manager. A track provides a means to share data, etc. from one Dialect to another. Properties can also be added by a Dialect for use in other Dialects. Typically only used by implementing Dialect constructors.
Kind: static typedef of typedefs
Properties
| Name | Type | Description |
|---|---|---|
| interpolate | SQLERInterpolateFunction | An interpolation function that can be used by Dialect implementations to interpolate configuration option values from underlying drivers within a Dialect (immutable). The convenience of doing so negates the need for an application that uses a Manager to import/require a database driver just to access driver constants, etc. |
| positionalBinds | SQLERPositionalBindsFunction | A function that will convert an SQL statement with named binds into positional binds. |
| bindExpansions | SQLERBindExpansionFunction | A function that takes an SQL statement with named binds and expands the bind variables into an array of values when they appear in the SQL statement |
| readable | SQLERStreamReadableProcessor | A function that uses a specified readable stream for batching large number of read executions. |
| writable | SQLERStreamWritable | A function that will generate a writable stream for batching large number of write executions. |