hub.eb?material_id=424&track_id=431

Transaction Manager


Every server-side event runs within a transaction. The system.transactionManager interface provides functions to manipulate the current transaction, including:

  • commitAndRestartTransaction(), commits the current transaction and starts a new transaction
  • rollbackAndRestartTransaction(), rolls back the current transaction and starts a new transaction.

An example pattern for managing transactions:

// fetching user data
var rows = tables.users.fetchTable();

while(rows.next()){
  try{
    // do something

    // commit the transaction
    system.transactionManager.commitAndRestartTransaction();
  }
  catch(e){
    log(e);

    // rollback the transaction
    system.transactionManager.rollbackAndRestartTransaction();
  }
}

Current Module

Related