changeset method
Returns records in table in CrdtChangeset format.
When sinceHlc is non-null, only records modified after that HLC string
are returned; when untilHlc is non-null, only records at or before it.
Both bounds are parsed and compared as HLCs, never as raw strings. Pass
neither (the default) for the full table, including tombstones — required
for persistence and sync; the bounded form serves range reconciliation's
leaf fetches.
Implementation
@override
Future<CrdtChangeset> changeset(
String table, {
String? sinceHlc,
String? untilHlc,
}) {
final changeset = _crdt.getChangeset(
onlyTables: [table],
modifiedAfter:
(sinceHlc == null || sinceHlc.isEmpty) ? null : Hlc.parse(sinceHlc),
);
if (untilHlc == null) return Future.value(changeset);
final until = Hlc.parse(untilHlc);
return Future.value({
for (final entry in changeset.entries)
entry.key: [
for (final record in entry.value)
if ((record['hlc'] as Hlc) <= until) record,
],
});
}