PgPool

PgPool

new PgPool(options)

Source:
Parameters:
Name Type Description
options object

Accepts properties ["name", "pgOptions", "poolOptions", "logger"]

Properties
Name Type Description
name string

Name your pool

pgOptions object

opts from node-postgres/wiki/Client#parameters

pgNative object

Use native bindings

poolOptions object

opts from node-pool#createpool

logger object

Inject your custom logger

Methods

acquire(priority, db) → {promise}

Source:

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}

Source:

Returns available connections count of the pool

Returns:

available connections count of the pool

Type
number

destroy(client) → {promise}

Source:

Destroy a Postgres connection.

Parameters:
Name Type Description
client object

Postgres connection

Returns:

Promise

Type
promise

drain() → {promise}

Source:

Drains the connection pool and call the callback id provided.

Returns:

Promise

Type
promise

getName() → {string}

Source:

Returns factory.name for this pool

Returns:

Name of the pool

Type
string

getPgOptions() → {object}

Source:

Returns this.pgOptions for this pool

Returns:

Postgres options given

Type
object

getPoolOptions() → {object}

Source:

Returns this.poolOptions for this pool

Returns:

pool options given

Type
object

getPoolSize() → {number}

Source:

Returns size of the pool

Returns:

size of the pool

Type
number

pendingCount() → {number}

Source:

Returns pending connections count of the pool

Returns:

pending connections count of the pool

Type
number

query(queryText, arrayValues) → {promise}

Source:

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}

Source:

Release a Postgres connection to the pool.

Parameters:
Name Type Description
client object

Postgres connection

Returns:

Promise

Type
promise

status() → {object}

Source:

Returns pool status and stats

Returns:

pool status and stats

Type
object