Skip to content

Documentation / @super-line/core / SelfCollectionStore

Interface: SelfCollectionStore ​

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

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:128


coordination ​

readonly coordination: "cluster"

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

Methods ​

apply() ​

apply(ops, origin): Awaitable<void>

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

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:93

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:138

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>


count()? ​

optional count(n, filter): Awaitable<number>

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

Rows of n matching filter (all rows when undefined), without materializing them. Absent ⇒ the server counts a snapshot.

Parameters ​

n ​

string

filter ​

Expr | undefined

Returns ​

Awaitable<number>

Inherited from ​

CollectionStoreBase.count


countBy()? ​

optional countBy(n, field, filter): Awaitable<ValueCount[]>

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

Every group of field over filter, unordered, as core's countValues forms them. Absent ⇒ the server groups a snapshot.

Parameters ​

n ​

string

field ​

string

filter ​

Expr | undefined

Returns ​

Awaitable<ValueCount[]>

Inherited from ​

CollectionStoreBase.countBy


fixedFields()? ​

optional fixedFields(n): readonly string[]

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

Fields of collection n whose value never changes for a key. An update without prev otherwise reaches every subscriber, a non-matching one as a data-less delete; the server skips a subscriber whose filter rules the new row out on these fields, since no version of the row ever matched it. Absent ⇒ none.

Parameters ​

n ​

string

Returns ​

readonly string[]

Inherited from ​

CollectionStoreBase.fixedFields


onChange() ​

onChange(cb): () => void

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

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:71

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:77

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.