Documentation / @super-line/core / RelayCollectionStore
Interface: RelayCollectionStore
Defined in: packages/core/src/collections.ts:90
A node-local replica. Core relays each batch across nodes over the Adapter and re-ingests remote batches through RelayCollectionStore.apply, so every node converges to the same rows.
Extends
CollectionStoreBase
Properties
clustering
readonlyclustering:"relay"
Defined in: packages/core/src/collections.ts:91
coordination
readonlycoordination:"local"
Defined in: packages/core/src/collections.ts:92
Methods
apply()
apply(
ops,origin):RowChange[]
Defined in: packages/core/src/collections.ts:108
See CollectionStore for the shared atomicity / error / timestamp contract. In relay mode apply also fires onChange once per resulting change before returning, and returns those changes.
The non-void return type is load-bearing — do not "simplify" it to void. It is the only thing making an async implementation a compile error, and that is the invariant which keeps a relayed write from echo-storming the cluster: the relay ingress fires-and-forgets (void apply(...)) so it can absorb a cross-node race in a try/catch, and the CRDT sibling clears a re-publish guard in finally. An async apply escapes that catch and clears that guard before the change is ever emitted. TypeScript's void-return rule accepts a function returning anything where void is declared, so apply(): void would silently permit async apply() again. RowChange[] does not.
(collections-crdt-libsql had to discover this constraint on its own — sync hot path, debounced onChange persistence — back when it lived only in prose. Now the compiler holds it.)
Parameters
ops
origin
string
Returns
close()?
optionalclose():Awaitable<void>
Defined in: packages/core/src/collections.ts:83
Release any resources held by the backend.
Returns
Awaitable<void>
Inherited from
CollectionStoreBase.close
conditionalApply()
conditionalApply(
conditions,ops,origin):boolean
Defined in: packages/core/src/collections.ts:110
Atomically check every condition and apply ops; returns false without changing anything when one is stale.
Parameters
conditions
ops
origin
string
Returns
boolean
onChange()
onChange(
cb): () =>void
Defined in: packages/core/src/collections.ts:81
Subscribe to every applied row change across all collections — core's single fan-out source. Returns an unsubscribe fn. Who fires it depends on the mode: a RelayCollectionStore fires it from apply; a SelfCollectionStore fires it from its replication feed instead. That difference is the one thing this seam cannot state in its types (the signature is identical either way), so it is stated here and pinned by the conformance suite.
Parameters
cb
(change) => void
Returns
() => void
Inherited from
CollectionStoreBase.onChange
read()
read(
n,id):unknown
Defined in: packages/core/src/collections.ts:67
Read one row by primary key — for write-policy prev and advisory FK checks. Undefined if absent.
Parameters
n
string
id
string
Returns
unknown
Inherited from
CollectionStoreBase.read
rowMeta()?
optionalrowMeta(n,ids):Awaitable<Record<string,RowTimestamps>>
Defined in: packages/core/src/collections.ts:73
Inspector-only: per-row RowTimestamps keyed by row id, for ids in collection n. The client subscribe path never sees these (rows stay exactly your schema) — timestamps are surfaced solely by the Control Center. Absent ⇒ the backend doesn't track row timestamps; the inspector shows no created/updated.
Parameters
n
string
ids
string[]
Returns
Awaitable<Record<string, RowTimestamps>>
Inherited from
CollectionStoreBase.rowMeta
snapshot()
snapshot(
n,query):Awaitable<unknown[]>
Defined in: packages/core/src/collections.ts:65
Materialize a collection's snapshot for the initial subscribe: filter → sort → offset/limit (core injects the policy filter).
Parameters
n
string
query
Returns
Awaitable<unknown[]>
Inherited from
CollectionStoreBase.snapshot