Constructor
new Manager(conf, cacheopt, loggingopt)
Creates a new database manager. Vendor-specific implementations should have constructors that accept properties defined by typedefs.Dialect
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
conf |
typedefs.SQLERConfigurationOptions
|
The configuration options |
|
cache |
typedefs.SQLERCache
|
<optional> |
the |
logging |
function
|
Boolean
|
<optional> |
the |
Members
Methods
(static) namedBindSequence(sql, count) → {Array.<String>}
Duplicates a SQL statement by sequentially incrementing named bind parameters by appending an increacing numeric count to each bind parameter
Parameters:
Name | Type | Description |
---|---|---|
sql |
String
|
The SQL statement that contains the bind names that will be sequenced |
count |
Integer
|
The total number of duplicates to make |
Returns:
- Type:
-
Array.<String>
The SQL statements that have been duplicated with sequentially numeric suffixes
Example
Manager.namedBindSequence('SELECT * FROM EXAMPLE X WHERE X.A = :a AND X.B = :b AND X.C = :c', 2);
// produces:
[
'SELECT * FROM EXAMPLE X WHERE X.A = :a1 AND X.B = :b1 AND X.C = :c1',
'SELECT * FROM EXAMPLE X WHERE X.A = :a2 AND X.B = :b2 AND X.C = :c2'
]
(async) addConnection(conn, privopt, cacheopt, loggingopt, returnErrorsopt) → {typedefs.SQLEROperationResults}
Adds a connection configuration to the manager and initializes the database connection
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
conn |
typedefs.SQLERConnectionOptions
|
The connection options that will be added to the manager |
|
priv |
typedefs.SQLERPrivateOptions
|
<optional> |
The private options that contain the connection credentials that should match |
cache |
typedefs.SQLERCache
|
<optional> |
the |
logging |
function
|
Boolean
|
<optional> |
the |
returnErrors |
Boolean
|
<optional> |
Truthy to return errors, otherwise, any encountered errors will be thrown |
Returns:
The results, each result[connectionName]
containing the truthy result from the dialect initialization for the given connection (or the errors when return
errors flag is set)
(async) close() → {typedefs.SQLEROperationResults}
Closes all database pools/connections/etc.
generateCacheKey(dialect, connName, methodName, ext) → {String}
Generates a key used for caching SQL methods
Parameters:
Name | Type | Description |
---|---|---|
dialect |
String
|
The database dialect |
connName |
String
|
The connection name |
methodName |
String
|
The SQL method name |
ext |
String
|
The SQL file extension |
Returns:
- Type:
-
String
The key used for caching
(async) getCacheKey(path, connName) → {String}
Gets a cache key for a given absolute path to an SQL file
Parameters:
Name | Type | Description |
---|---|---|
path |
String
|
The absolute path to the SQL file |
connName |
String
|
The connection name to get the cache key for |
Returns:
- Type:
-
String
The cache key for the given path
(async) init(returnErrorsopt) → {typedefs.SQLEROperationResults}
Initializes the configured database connections
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
returnErrors |
Boolean
|
<optional> |
Truthy to return errors, otherwise, any encountered errors will be thrown |
Returns:
The results, each result[connectionName]
containing the truthy result from the dialect initialization for the given connection (or the errors when return
errors flag is set)
(async) preparedFunctionCount(…connNamesopt) → {typedefs.SQLEROperationResults}
Gets the number of prepared SQL functions on either all the connections used by the manager or on the specified connection names.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
connNames |
String
|
<optional> <repeatable> |
The connection names to perform the check on (defaults to all connections) |
Returns:
The results, each result[connectionName]
containing the number of generated prepared SQL functions for the given connection
(async) scan(removeOrphansopt, …connNames) → {typedefs.SQLEROperationResults}
Scans directories/subdirectories for SQL files and generates prepared functions on either all the connections used by the manager or on the specified connection names.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
removeOrphans |
Boolean
|
<optional> |
true |
Truthy to remove orphaned prepared functions that no longer have an SQL file associated with them |
connNames |
String
|
<repeatable> |
The connection names to scan for SQL files for when generating prepared functions |
Returns:
The results, each result[connectionName]
containing the number of SQL prepared functions for the given connection
(async) setCache(cacheopt, isTransferopt, …connNames) → {typedefs.SQLEROperationResults}
Sets the caching mechanism that will be used that will determine the frequency of reading SQL source files. Omit the connection names to set the cache on all connections used by the manager.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cache |
typedefs.SQLERCache
|
<optional> |
the |
isTransfer |
Boolean
|
<optional> |
Truthy when the passed |
connNames |
String
|
<repeatable> |
The connection names to set the cache for |
Returns:
The results, each result[connectionName]
containing the number of cached keys transferred for the given connection
(async) state(optsopt, …connNamesopt) → {typedefs.SQLEROperationResults}
Composes the typedefs.SQLERState
on either all the connections used by the manager or on the specified connection names.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opts |
typedefs.SQLEROperationOptions
|
<optional> |
The |
connNames |
String
|
<optional> <repeatable> |
The connection names to perform the check on (defaults to all connections) |
Returns:
The results, each result[connectionName]
containing the typedefs.SQLERState
for the given connection