Skip to content

API StaticPool

Michael Anderson edited this page Dec 12, 2017 · 4 revisions

The StaticPool is a Pool implementation where the pools for a given connection URL are static. That is two constructors with the same URL will still use the same pool of connections.

Syntax

var pool = new StaticPool( connection: string | ConnectionObject, poolSize: integer, driver?: DatabaseDriver )

Arguments

connection

Type: string or ConnectionObject

Defines the connection parameters for all connections in the pool.

poolSize

Type: integer

Defines the number of connections in the pool.

driver

Type: DatabaseDriver

An optional parameter. Used to pass in a specific driver class. If this is specified, the driver name is ignored in the connection argument.

Properties

Available

Type: integer

Returns the number of available connections in the pool.

InUse

Type: integer

Returns the number of connection in use from the pool.

Count

Type: integer

Returns the total number of connections n the pool

Methods

getConnection() => PooledConnection

Retrieves an available connection from the pool, or adds one if required.

Returns: PooledConnection

close() => Promise

Closes the pool and forces all connections in the pool to close;

Returns: Promise

Returns a boolean promise that resolves when all the connections in the pool have been closed.

Clone this wiki locally