@yorozu/db
v1.0.73
Published
injectable collection store (memory driver)
Readme
@yorozu/db
Injectable collection store (Collection / Db / DbDriver) plus openMemoryDb.
Implementing a driver
Public types must never mention IndexedDB or SQLite. Drivers live in other packages.
Musts:
- Reserved index
"__pk": primary-key walk in key order, even if it is not inCollectionDef.indexes. scan(..., { direction: "rev" })returns the highest keys first; omit = fwd.scan(..., { keysOnly: true })must not materialize row values. OmitScanHit.valueentirely. Do not clone blobs.- Bounds use
compareIndexKey: number < string < array. A shorter prefix-equal array is less ([cutoff] < [cutoff, 0]). Prefix TTL:scan("by-evict", { lt: [cutoff], keysOnly: true })matches[storedAt, bytes]withstoredAt < cutoff. getManypreserves input key order; missing keys arenull.- Default
putflush is"now"."batch"buffers untildb.flush()or the next"rw"transact commit, not"r". Memory treats"batch"as"now";flush()still resolves as a no-op. flush({ reason, signal }):reasonis"idle" | "hidden" | "explicit"for the caller (write semantics unchanged). Already-abortedsignalrejects withAbortError(orsignal.reason) without work. Read transactflushstays a no-op.- Nested
transactthrows. Concurrenttransacton overlapping names serializes. - Unknown collection / unknown index throws.
- Primary keys are strings (
String(...)). IndexkeyPathis top-level field names only (including compound arrays), not dotted paths.
