open static method
Opens the database snapshots holds.
With tables, only those tables are kept in snapshots and the others
last as long as the session: a store that keeps a small record -- the
visitor's consent -- beside a table that grows with every event would
otherwise rewrite the growing one on every write.
Implementation
static Future<DVSnapshotDatabaseAdapter> open(
DVTableSnapshots snapshots, {
Set<String>? tables,
}) async {
final DVSnapshotDatabaseAdapter adapter =
DVSnapshotDatabaseAdapter._(snapshots, tables);
final Map<String, String> saved = await snapshots.readAll();
for (final MapEntry<String, String> table in saved.entries) {
if (tables != null && !tables.contains(table.key)) continue;
adapter._memory.importTable(
table.key,
jsonDecode(table.value) as Map<String, Object?>,
);
}
return adapter;
}