Class: EasyPG

EasyPG(config, DefaultPoolopt)

new EasyPG(config, DefaultPoolopt)

EasyPG class for simple queries and transactions using a supplied Pool or creating a new pg.Pool.
Parameters:
Name Type Attributes Description
config Object | string Can be a connection string or an object
Properties
Name Type Description
user string DB username
password string DB password
host string DB hostname
port string DB port number
database string Database name to connect to
DefaultPool Pool <optional>
Pool constructor. If not provided, default pg.Pool will be used
Source:

Methods

end() → {Promise}

This ends the pool. It will not be possible to call `.query()` nor `.runTransaction()` on this instance after calling `.end()`.
Source:
Returns:
Type
Promise

query(query) → {Promise}

Gets a client from the pool and runs the query.
Parameters:
Name Type Description
query Object A query config object
Properties
Name Type Description
text String
params array | function Array of parameters or function returning array of parameters
Source:
Returns:
Type
Promise

runTransaction(queries) → {Promise}

Runs each query in sequence as part of a transaction. Each object in the `queries` array must have `text` and `params` properties. If provided, the optional `handler` property will be called after its associated query resolves.
Parameters:
Name Type Description
queries Array An array of query config objects
Source:
Returns:
Type
Promise