liveKeys method
All live (non-tombstoned) keys in table whose key starts with
prefix.
Like liveFields but without values — returns only metadata so operations such as Collection.length can avoid I/O. Must be safe to call synchronously after init.
Implementation
@override
Set<String> liveKeys(String table, String prefix) {
if (_db == null) return const {};
final rows = prefix.isEmpty
? _open.select(
'SELECT key FROM crdt_records '
'WHERE collection = ? AND is_deleted = 0',
[table],
)
: _open.select(
'SELECT key FROM crdt_records '
'WHERE collection = ? AND is_deleted = 0 AND substr(key, 1, ?) = ?',
[table, prefix.length, prefix],
);
return {for (final r in rows) r['key'] as String};
}