write<T> abstract method

T write<T>(
  1. T callback(
    1. Isar isar
    )
)

Create a synchronous read-write transaction.

Unlike read operations, write operations in Isar must be wrapped in an explicit transaction.

When a write transaction finishes successfully, it is automatically committed, and all changes are written to disk. If an error occurs, the transaction is aborted, and all the changes are rolled back. Transactions are “all or nothing”: either all the writes within a transaction succeed, or none of them take effect to guarantee data consistency.

Example:

isar.write((isar) {
  final user = User(name: 'John');
  isar.users.put(user);
});

Implementation

T write<T>(T Function(Isar isar) callback);