transaction<T> method
Enters a database transaction, performing the actions within,
and returning the results of f
.
If f
fails, the transaction will be rolled back, and the
responsible exception will be re-thrown.
Whether nested transactions are supported depends on the underlying driver.
Implementation
@override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
T? returnValue = await _connection.transaction((ctx) async {
try {
// TODO: To be refactored
//logger.fine('Entering transaction');
//var tx = MariaDbExecutor(conn, logger: logger);
//TransactionContext transactionContext = ctx;
return await f(this);
} catch (e) {
logger.severe('Failed to run transaction', e);
rethrow;
}
});
return returnValue!;
}