Documentation / @super-line/server / ServerCollectionHandle
Interface: ServerCollectionHandle<Row>
Defined in: collections/types.ts:130
Server-authoritative handle for a collection (srv.collection('messages')). Writes bypass row policy (server is authoritative) but are still schema-validated, fan out, and — under relay — replicate across nodes exactly like a client batch. The door for business-logic mutations that a contract request handler owns.
Type Parameters
Row
Row = unknown
Methods
count()
count(
filter?):Promise<number>
Defined in: collections/types.ts:142
Count the rows matching filter (omit it for the whole collection). Server-side, policy-free, like snapshot.
Parameters
filter?
Returns
Promise<number>
countBy()
countBy(
field,filter?,opts?):Promise<ValueCount[]>
Defined in: collections/types.ts:148
Count rows per value of field over filter — a facet's counts. A scalar groups by value, null included; an array counts each row once per distinct element, as has matches it. Most rows first unless order: 'value'. Server-side, policy-free, like snapshot.
Parameters
field
string
filter?
opts?
Returns
Promise<ValueCount[]>
delete()
delete(
id):Promise<void>
Defined in: collections/types.ts:136
Delete a row by id (idempotent).
Parameters
id
string
Returns
Promise<void>
insert()
insert(
row):Promise<void>
Defined in: collections/types.ts:132
Insert a row (its key field becomes the id). Throws CONFLICT if the id already exists.
Parameters
row
Row
Returns
Promise<void>
read()
read(
id):Promise<Row|undefined>
Defined in: collections/types.ts:138
Read one row by id, or undefined.
Parameters
id
string
Returns
Promise<Row | undefined>
rowMeta()?
optionalrowMeta(ids):Promise<Record<string,RowTimestamps>>
Defined in: collections/types.ts:150
Inspector-only: per-row created/updated timestamps keyed by id. Absent unless the backend tracks them.
Parameters
ids
string[]
Returns
Promise<Record<string, RowTimestamps>>
snapshot()
snapshot(
query?):Promise<Row[]>
Defined in: collections/types.ts:140
Materialize a snapshot (filter/sort/limit); omit the query for the whole collection. Server-side, policy-free.
Parameters
query?
Returns
Promise<Row[]>
update()
update(
row):Promise<void>
Defined in: collections/types.ts:134
Replace a row by its key (LWW). Throws NOT_FOUND if absent.
Parameters
row
Row
Returns
Promise<void>