Class: Connection

Connection

new Connection(ifx, poolopt, optsopt)

Class representing a connection to a database
Parameters:
Name Type Attributes Description
ifx Ifx Native object instance
pool Pool <optional>
Connection pool associated with this connection
opts object <optional>
Constructor options
Source:

Methods

acquire(context) → {Promise.<Connection, Error>}

Acquire this connection from the pool
Parameters:
Name Type Description
context string Context ID to be used when acquiring the connection
Source:
Returns:
- A promise to a connection object or an Error if rejected.
Type
Promise.<Connection, Error>

connect(params) → {Promise.<Connection, Error>}

Open a connection to a database
Parameters:
Name Type Description
params object Connection parameters
Source:
Returns:
- A promise to a connection object or an Error if rejected.
Type
Promise.<Connection, Error>

id() → {string}

Return the connection ID
Source:
Returns:
- ID generated for this connection.
Type
string

ifx() → {Ifx}

Return the instance of the native binding used with this connection
Source:
Returns:
- Native object instance.
Type
Ifx

index() → {integer}

Return the connection pool index
Source:
Returns:
- Connection pool index associated with this connection.
Type
integer

options(opts)

Set options
Parameters:
Name Type Description
opts object Options
Source:

prepare(sql, optsopt) → {Promise.<Statement, Error>}

Prepare a statement
Parameters:
Name Type Attributes Description
sql string SQL statement to prepare
opts object <optional>
Options to be passed to the Statement constructor
Source:
Returns:
- A promise to a statement object or an Error if rejected.
Type
Promise.<Statement, Error>

release(context)

Release this connection back to the pool
Parameters:
Name Type Description
context string Context ID to be used when releasing the connection
Source: