Module: Session

This module specifies the interface of an X DevAPI Session, which is a logical abstraction over a MySQL server connection.

Methods


close()

Close the underlying connection to the database or release it back into a connection pool.
Returns:
Type
Promise

commit()

Commit an ongoing database transaction in the scope of the current session.
Returns:
Type
Promise

createSchema(name)

Create a new database schema.
Parameters:
Name Type Description
name string name of the schema
Returns:
A Promise that resolves to the schema instance.
Type
Promise.<module:Schema>

dropSchema(name)

Drop a database schema. If the schema does not exist, nothing happens.
Parameters:
Name Type Description
name string name of the schema
Returns:
Returns true if the schema with the given name was removed from the database or false if it did not exist in the database.
Type
Promise.<boolean>

executeSql(sql)

Executes a raw SQL statement in the database and reports back any results.
Parameters:
Name Type Description
sql string SQL statement
Deprecated:
Returns:
Type
Promise.<module:SqlExecute>

getDefaultSchema()

Retrieve the instance of any default schema associated to the underlying database connection. If there is no default schema, the instance will be undefined.
Returns:
Type
module:Schema

getSchema(name)

Retrieve an instance of a schema with the given name.
Parameters:
Name Type Description
name string name of the schema
Returns:
Type
module:Schema

getSchemas()

Retrieve a list of instances of all the existing schemas in the database.
Returns:
Type
Promise.<Array.<module:Schema>>

inspect()

Retrieve the details of the underlying database connection.
Returns:
Type
Object

releaseSavepoint(name)

Release a given savepoint from an ongoing transaction in the database.
Parameters:
Name Type Description
name string name of the savepoint
Returns:
Type
Promise

rollback()

Roll back an ongoing database transaction in the scope of the current session.
Returns:
Type
Promise

rollbackTo(name)

Go back to an existing savepoint within the scope of an ongoing transaction.
Parameters:
Name Type Description
name string name of the savepoint
Returns:
Type
Promise

setSavepoint( [name])

Create a new savepoint with the given name in the scope of ongoing transaction. If a savepoint name is not provided, one will be auto-generated.
Parameters:
Name Type Argument Description
name string <optional>
name of the savepoint
Returns:
A Promise that resolves to the name of the savepoint.
Type
Promise.<string>

sql(statement)

Creates a new operational context to execute a SQL statement in the database.
Parameters:
Name Type Description
statement string SQL statement
Returns:
Type
Promise.<module:SqlExecute>

startTransaction()

Begin a new database transaction in the scope of the current session.
Returns:
Type
Promise