Class: Statement

Statement

new Statement(conn, optsopt)

Class representing a prepared statement
Parameters:
Name Type Attributes Description
conn Connection Connection object
opts object <optional>
Constructor options
Properties
Name Type Attributes Default Description
reusable boolean <optional>
true Flag to indicate whether this statement should be reusable.
Source:

Methods

context() → {string}

Return the context ID associated with this statement
Source:
Returns:
- Context ID
Type
string

exec(argsopt) → {Promise.<Cursor, Error>}

Execute the prepared statement
Parameters:
Name Type Attributes Description
args string | Array <optional>
Arguments to be used when executing the prepared statement.
Source:
Returns:
- A promise to a results cursor object or an Error if rejected.
Type
Promise.<Cursor, Error>

flags() → {object|boolean}

Return statement flags
Source:
Returns:
  • flags - Statement flags
    Type
    object
  • flags.reusable - Flag to indicate whether this statement should be reusable.
    Type
    boolean

free() → {Promise.<string, Error>}

Free the prepared statement
Source:
Returns:
- A promise to a string which would contain the statement ID freed or an Error if rejected.
Type
Promise.<string, Error>

options(opts)

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

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

Prepare a statement
Parameters:
Name Type Description
sql string SQL statement to prepare
Source:
Returns:
- A promise to a statement object or an Error if rejected.
Type
Promise.<Statement, Error>