DbPool - do-/node-doix-db GitHub Wiki
DbPool
is a doix
ResourcePool of connections to a database, an ancestor for database driver wrappers.
All derived pools are presumed to be transaction safe, so:
- every connection just came from a pool is in auto commit mode (
db.txn === null
); - prior to releasing, any unfinished transactions are rolled back automatically.
Constructor
This is an abstract class, so the constructor must be invoked only in descendants, as super ()
.
super ({
// logger: ConsoleLogger.DEFAULT,
// eventLoggerClass: require ('MySpecialDbLogger'),
})
Options
Name | Description |
---|---|
logger |
A winston Logger. |
Properties
Name | Description |
---|---|
logger |
Copy of the logger constructor option |
model |
a DbModel representing the database structure |
lang |
a DbLang representing the database language dialect |
shared |
A Set of property names to inject into each resource created. By default, contains 'model' and 'lang' . |
Methods
onAcquire (db)
This asynchronous method is registered with the acquire
event and thus is executed before any asynchronous requests to the connection freshly acquired in the context of a Job. Does nothing in the base implementation. Reserved for transaction auto start, setting variables etc.