Skip to content

Documentation / @super-line/core / SelfCollectionStore

Interface: SelfCollectionStore

Defined in: packages/core/src/collections.ts:117

A backend that owns its own cross-node propagation (a central Postgres + a per-node replication feed). Core never relays for it; it fans out only to this node's local subscribers.

Extends

  • CollectionStoreBase

Properties

clustering

readonly clustering: "self"

Defined in: packages/core/src/collections.ts:118


coordination

readonly coordination: "cluster"

Defined in: packages/core/src/collections.ts:119

Methods

apply()

apply(ops, origin): Awaitable<void>

Defined in: packages/core/src/collections.ts:126

See CollectionStore for the shared atomicity / error / timestamp contract. In self mode apply persists to the central backend and returns nothing, and does not fire onChange: the backend's replication feed surfaces the change on every node, including this one, so firing here would double-deliver. It may be async — nothing relays it, so the synchrony relay demands does not apply.

Parameters

ops

ResolvedRowOp[]

origin

string

Returns

Awaitable<void>


close()?

optional close(): 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): Awaitable<boolean>

Defined in: packages/core/src/collections.ts:128

Atomically check every condition and apply ops; returns false without changing anything when one is stale.

Parameters

conditions

RowCondition[]

ops

ResolvedRowOp[]

origin

string

Returns

Awaitable<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()?

optional rowMeta(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

CollectionQuery

Returns

Awaitable<unknown[]>

Inherited from

CollectionStoreBase.snapshot

Released under the MIT License.