Class: Transaction

x2node-dbos~ Transaction

Transaction.

new Transaction(dbDriver, connection)

Note: The constructor is not available to the client code. Transaction instances can be created by the DBO factory's newTransaction() method.
Parameters:
Name Type Description
dbDriver module:x2node-dbos.DBDriver DB driver.
connection * DB driver specific connection object.

Members


<readonly> connection :*

Underlying DB driver specific connection object associated with the transaction.
Type:
  • *

<readonly> dbDriver :module:x2node-dbos.DBDriver

The database driver.
Type:

Methods


commit( [passThrough])

Commit the transaction.
Parameters:
Name Type Argument Description
passThrough * <optional>
Arbitrary value to have the promise to return on success. May not be a promise itself (use promise chaining for that).
Throws:
If the transaction has not been started or if it has already finished.
Type
module:x2node-common.X2UsageError
Returns:
Promise that is resolved with the passThrough value if the transaction committed successfully and is rejected with an error object in the case of failure.
Type
Promise

isActive()

Tell if the transaction is started (and not finished).
Returns:
true if active transaction.
Type
boolean

rollback( [passThrough])

Rollback the transaction.
Parameters:
Name Type Argument Description
passThrough * <optional>
Arbitrary value to have the promise to return on both success and failure. May not be a promise itself (use promise chaining for that).
Throws:
If the transaction has not been started or if it has already finished.
Type
module:x2node-common.X2UsageError
Returns:
Promise that is resolved with the passThrough value if the transaction rolled back successfully and is rejected with with the same passThrough value in the case of failure. The rollback failure error is only logged.
Type
Promise

start( [passThrough])

Start the transaction.
Parameters:
Name Type Argument Description
passThrough * <optional>
Arbitrary value to have the promise to return on success. May not be a promise itself (use promise chaining for that).
Throws:
If the transaction is already in progress or if it has already finished.
Type
module:x2node-common.X2UsageError
Returns:
Promise that is resolved with the passThrough value if the transaction started successfully and is rejected with an error object in the case of failure.
Type
Promise