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
cancelRequest(handler) → {PgConnection}
Send a request cancellation message to tell the server to cancel processing request in this connection.
Note: Use this with caution because the cancellation signal may or may not have any effect.
Note: Use this with caution because the cancellation signal may or may not have any effect.
Parameters:
Name | Type | Description |
---|---|---|
handler |
function | the handler notified if cancelling request is sent |
- Source:
Returns:
a reference to this, so the API can be used fluently
- Type
- PgConnection
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
processId() → {number}
- Source:
Returns:
The process ID of the target backend
- Type
- number
query(sql, handler) → {PgConnection}
Parameters:
Name | Type | Description |
---|---|---|
sql |
string | |
handler |
function |
- Source:
Returns:
- Type
- PgConnection
secretKey() → {number}
- Source:
Returns:
The secret key for the target backend
- Type
- number