atomically method

  1. @override
Future<void> atomically(
  1. Future<void> writes()
)

Runs writes in one SQLite transaction: a process killed half-way through a document's records commits none of them, rather than leaving the document half-written on disk.

Implementation

@override
Future<void> atomically(Future<void> Function() writes) async {
  _open.execute('BEGIN');
  try {
    await writes();
    _open.execute('COMMIT');
  } catch (_) {
    _open.execute('ROLLBACK');
    rethrow;
  }
}