Class: TxFactory

x2node-dbos~ TxFactory

Database transactions factory.

new TxFactory(dbDriver, ds)

Note: The constructor is not accessible from the client code. Instances are created using DBO factory's createTxFactory() method.
Name Type Description
dbDriver module:x2node-dbos.DBDriver DB driver.
ds module:x2node-dbos.DataSource Connections data source.



Create and execute a database transaction.
Name Type Description
cb function Callback function with the transaction logic. The function is passed the transaction as its only argument. The transaction is started by the time the callback is called. The callback may return a Promise. If the promise is rejected or the callback throws an error, the transaction is automatically rolled back. Otherwise, the transaction is committed.
The promise of the callback result. If the promise is successfully fulfilled, the transaction is committed. If an error happens and the transaction is rolled back, the promise is rejected with the error.