write<T> method
T
write<T>(
- T writeCallback()
Synchronously calls the provided callback inside a write transaction.
If no exception is thrown from within the callback, the transaction will be committed. It is more efficient to update several properties or even create multiple objects in a single write transaction.
Implementation
T write<T>(T Function() writeCallback) {
assert(!_isFuture<T>(), 'writeCallback must be synchronous');
final transaction = beginWrite();
try {
T result = writeCallback();
transaction.commit();
return result;
} catch (e) {
transaction.rollback();
rethrow;
}
}