withTransaction<T> method

Future<T> withTransaction<T>(
  1. TransactionHandler<T> transactionHandler
)

Begins a new a new transaction.

A transaction can touch only a limited number of entity groups. This limit is currently 5.

Implementation

// TODO: Add retries and/or auto commit/rollback.
Future<T> withTransaction<T>(TransactionHandler<T> transactionHandler) {
  return datastore
      .beginTransaction(crossEntityGroup: true)
      .then((datastoreTransaction) {
    var transaction = Transaction(this, datastoreTransaction);
    return transactionHandler(transaction);
  });
}