read<T> abstract method

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

Create a synchronous read transaction.

Explicit read transactions are optional, but they allow you to do atomic reads and rely on a consistent state of the database inside the transaction. Internally Isar always uses implicit read transactions for all read operations.

It is recommended to use an explicit read transactions when you want to perform multiple subsequent read operations.

Example:

final (user, workspace) = isar.read((isar) {
  final user = isar.users.where().findFirst();
  final workspace = isar.workspaces.where().findFirst();
  return (user, workspace);
});

Implementation

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