new PgPool(options)
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Accepts properties ["name", "pgOptions", "poolOptions", "logger"] Properties
|
Methods
acquire(priority, db) → {promise}
Acquire a Postgres connection and use an optional priority.
Parameters:
Name | Type | Description |
---|---|---|
priority |
number | priority list number |
db |
number | Use the db with range {0-16} |
Returns:
Promise resolve with the connection or Error
- Type
- promise
availableCount() → {number}
Returns available connections count of the pool
Returns:
available connections count of the pool
- Type
- number
destroy(client) → {promise}
Destroy a Postgres connection.
Parameters:
Name | Type | Description |
---|---|---|
client |
object | Postgres connection |
Returns:
Promise
- Type
- promise
drain() → {promise}
Drains the connection pool and call the callback id provided.
Returns:
Promise
- Type
- promise
getName() → {string}
Returns factory.name for this pool
Returns:
Name of the pool
- Type
- string
getPgOptions() → {object}
Returns this.pgOptions for this pool
Returns:
Postgres options given
- Type
- object
getPoolOptions() → {object}
Returns this.poolOptions for this pool
Returns:
pool options given
- Type
- object
getPoolSize() → {number}
Returns size of the pool
Returns:
size of the pool
- Type
- number
pendingCount() → {number}
Returns pending connections count of the pool
Returns:
pending connections count of the pool
- Type
- number
query(queryText, arrayValues) → {promise}
Run Postgres query Client#querytext-arrayvalues
Parameters:
Name | Type | Description |
---|---|---|
queryText |
string | sql query |
arrayValues |
array | array values |
Returns:
Promise resolve with the result or Error
- Type
- promise
release(client) → {promise}
Release a Postgres connection to the pool.
Parameters:
Name | Type | Description |
---|---|---|
client |
object | Postgres connection |
Returns:
Promise
- Type
- promise
status() → {object}
Returns pool status and stats
Returns:
pool status and stats
- Type
- object