-
Notifications
You must be signed in to change notification settings - Fork 2
DbPoolPg
DbPoolPg
is a doix
DbPool of connections to a PostgreSQL database.
It is a thin wrapper over the native driver's connection pool.
It provides access to databases for business methods executed by Jobs by injecting there proxy variables. For example, normally, the main application's database is represented by the pool named "db", so each Job
have the .db
property visible to business methods as this.db
, instance of DbClientPg.
The class is designed to provide some Application's initialization parameters:
const {Application} = require ('doix')
const {DbPoolPg} = require ('doix-db-postgresql')
const app = new Application ({
pools: {
db: new DbPoolPg ({
db: {host: '127.0.0.1', port: 5432},
// logger: ConsoleLogger.DEFAULT,
// eventLoggerClass: require ('MySpecialDbLogger'),
})
}
})
Name | Description |
---|---|
db |
options forwarded to the native constructor |
logger |
A winston like Logger object. Unless mentioned, all output goes to the containing Job's logger. |
lang |
An instance of DbLangPg or its descendant. A new DbLangPg () is used by default |
eventLoggerClass |
An EventLogger descendant class to create for each new client instance. By default, DbEventLogger is used. |
Name | Description |
---|---|
pool |
The pg.Pool instance used by this wrapper |
logger |
Copy of the logger constructor option |
lang |
Copy of the lang constructor option |
eventLoggerClass |
Copy of the eventLoggerClass constructor option or DbEventLogger by default |
wrapper |
always DbClientPg |
model |
a DbModel representing the database structure |
globals |
an object of properties to be injected in each resource as is. For function valued properties, this works like using mixins. |
This mandatory method is implemented by calling the native connect ().model a DbModel representing the database structure globals an object of properties to be injected in each resource as is. For function valued properties, this works like using mixins.
Returns booean
value indicating whether a BEGIN
statement must be issued before any other by the given dbClientPg
. Used internally by onAcquire. In the default implementation, always returns false
. Presumed to use the dbClientPg.job.rq
value, e. g. check for magic parameter names like 'action'
.
Returns booean
value indicating whether the argument is a DbPoolPg instance using the same host
, port
, database
and user
connection parameters as this
.