iterate method

  1. @override
Stream<CommitEntry> iterate({
  1. int? fromCommitId,
  2. bool where(
    1. CommitEntry
    )?,
})
override

Iterate every commit entry in commitId order. If fromCommitId is provided, yields only entries with commitId >= fromCommitId. If where is provided, only entries for which where(entry) returns true are yielded; the rest are silently skipped. Used by sync, by migration, and by anything that needs full-log traversal.

After 3.5a's dedup invariant, the box has at most one entry per atKey, so a full-log walk yields one entry per atKey in commit-id order.

Implementation

@override
Stream<CommitEntry> iterate({
  int? fromCommitId,
  bool Function(CommitEntry)? where,
}) async* {
  final rows = fromCommitId == null
      ? _db.raw.select(
          'SELECT atkey, commit_id, operation, op_time FROM commit_log '
          'ORDER BY commit_id;')
      : _db.raw.select(
          'SELECT atkey, commit_id, operation, op_time FROM commit_log '
          'WHERE commit_id >= ? ORDER BY commit_id;',
          [fromCommitId]);
  for (final row in rows) {
    final entry = _entryFromRow(row);
    if (where == null || where(entry)) yield entry;
  }
}