Class: Session

Session


new Session( [properties])

Constructor for a X plugin Session
Parameters:
Name Type Argument Description
properties URI <optional>

Methods


commit()

Commit a transaction This will commit a transaction on the server. On success the returned Promise will resolve to true, else the Promise will be rejected with an Error.
Returns:
Type
Promise.<boolean>

createSchema(schema)

Create a schema in the database.
Parameters:
Name Type Description
schema string Name of the Schema
Returns:
Type
Promise.<module:Schema>

dropSchema(name)

Drop a schema (without failing even if it does not exist).
Parameters:
Name Type Description
name string schema name
Returns:
- Promise resolving to true on success
Type
Promise.<boolean>

executeSql(sql [, args])

Execute a raw SQL statement.
Parameters:
Name Type Argument Description
sql string SQL statement
args * <optional>
<repeatable>
query placeholder values
Deprecated:
  • since version 8.0.12. Will be removed in future versions. Use Session.sql() instead.
Returns:
Type
module:SqlExecute

getDefaultSchema()

Get the default schema instance.
Returns:
The default schema bound to the current session.
Type
module:Schema

getSchema(name)

Get instance of Schema object for a specific database schema This will always succeed, even if the schema doesn't exist. Use Schema#existsInDatabase on the returned object to verify the schema exists.
Parameters:
Name Type Description
name string Name of the schema (database)
Returns:
Type
module:Schema

getSchemas()

Get schemas
Returns:
Promise resolving to a list of Schema instances.
Type
Array.<module:Schema>

releaseSavepoint( [name])

Release a transaction savepoint with the given name.
Parameters:
Name Type Argument Description
name string <optional>
savepoint name
Returns:
Type
Promise

rollback()

Rollback a transaction This will rollback the current transaction. On success the returned Promise will resolve to true, else the Promise will be rejected with an Error. Create a Schema in the database
Returns:
Type
Promise.<boolean>

rollbackTo( [name])

Rollback to a transaction savepoint with the given name.
Parameters:
Name Type Argument Description
name string <optional>
savepoint name
Returns:
Type
Promise

setSavepoint( [name])

Create a new transaction savepoint. If a name is not provided, one will be generated using the connector-nodejs- format.
Parameters:
Name Type Argument Description
name string <optional>
savepoint name
Returns:
Promise that resolves to the name of the savepoint.
Type
Promise.<string>

sql(sql)

Execute a raw SQL statement.
Parameters:
Name Type Description
sql string SQL statement
Returns:
Type
module:SqlExecute

startTransaction()

Start a transaction This will start a transaction on the server. On success the returned Promise will resolve to true, else the Promise will be rejected with an Error.
Returns:
Type
Promise.<boolean>