Class: PgConnection

reactive-pg-client-js/pg_connection~ PgConnection

new PgConnection()

A connection to Postgres.
Source:

Methods

begin() → {PgTransaction}

Begin a transaction and returns a PgTransaction for controlling and tracking this transaction.

When the connection is explicitely closed, any inflight transaction is rollbacked.

Source:
Returns:
the transaction instance
Type
PgTransaction

close()

Close the current connection after all the pending commands have been processed.
Source:

closeHandler(handler) → {PgConnection}

Set an handler called when the connection is closed.
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
PgConnection

exceptionHandler(handler) → {PgConnection}

Set an handler called with connection errors.
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
PgConnection

isSSL() → {boolean}

Source:
Returns:
whether the connection uses SSL
Type
boolean

notificationHandler(handler) → {PgConnection}

Set an handler called when the connection receives notification on a channel.

The handler is called with the PgNotification and has access to the channel name and the notification payload.

Parameters:
Name Type Description
handler function the handler
Source:
Returns:
the transaction instance
Type
PgConnection

prepare(sql, handler) → {PgConnection}

Create a prepared query.
Parameters:
Name Type Description
sql string the sql
handler function the handler notified with the prepared query asynchronously
Source:
Returns:
Type
PgConnection

preparedBatch(sql, batch, handler) → {PgConnection}

Parameters:
Name Type Description
sql string
batch Array.<Tuple>
handler function
Source:
Returns:
Type
PgConnection

preparedQuery(sql, arguments, handler) → {PgConnection}

Parameters:
Name Type Description
sql string
arguments Tuple
handler function
Source:
Returns:
Type
PgConnection

query(sql, handler) → {PgConnection}

Parameters:
Name Type Description
sql string
handler function
Source:
Returns:
Type
PgConnection