/utils/dbs

Database connection and query management module that creates connection pools for multiple databases based on xyzEnvironment variables prefixed with 'DBS_'.

The node-postgres package is required to create a new connection Pool for DBS connections.

Requires

Methods

(async, inner) clientQuery(pool, query, variablesopt, timeoutopt) → {Promise.<(Array|Error)>}

The clientQuery method creates a client connection from the provided Pool and executes a query on this pool.

Parameters:
NameTypeAttributesDescription
poolPool

The node-postgres connection Pool for a Client connection.

querystring

SQL query to execute

variablesArray<optional>

Parameters for the SQL query

timeoutnumber<optional>

Statement timeout in milliseconds

Throws:

Database connection or query errors

Type
Error
Returns:

Query results or error object

Type: 
Promise.<(Array|Error)>

(inner) sleep(ms) → {Promise.<void>}

Helper function to pause execution

Parameters:
NameTypeDescription
msnumber

Time to sleep in milliseconds

Returns:
Type: 
Promise.<void>