Type Alias DatasetDeclaration<Row>
maxBytes: number;
maxRows: number;
maxStaleMs?: number;
provision?: "always" | "auto";
schema: string;
scope: "public" | "principal";
changes(
since: number,
ctx: DatasetContext,
): MaybePromise<DatasetChanges | "reset">;
fields?(viewer: Identity | null, row: Row): readonly string[];
head(ctx: DatasetContext): MaybePromise<DatasetHead>;
horizon(ctx: DatasetContext): MaybePromise<number>;
key(row: Row): string;
read(
ids: readonly string[],
ctx: DatasetContext,
): MaybePromise<readonly Row[]>;
seed(
ctx: DatasetSeedContext,
): MaybePromise<
| readonly Row[]
| Iterable<readonly Row[], any, any>
| AsyncIterable<readonly Row[], any, any>,
>;
}
Type Parameters
- Row extends DatasetRow = DatasetRow
Methods
changes
-
the net change since
since, orresetwhen it cannot answerParameters
- since: number
- ctx: DatasetContext
Returns MaybePromise<DatasetChanges | "reset">
Optionalfields
-
Principal datasets only: the field names of
rowthatviewermay hold, fromnullfor an anonymous request. The server sends each viewer only those fields, so the device never holds the others. Absent, every field goes to every viewer.Returns readonly string[]
head
-
the current cursor, read before a seed so every later change reaches the device
Parameters
- ctx: DatasetContext
Returns MaybePromise<DatasetHead>
horizon
-
the oldest cursor
changescan still answer; a device older than this reseedsParameters
- ctx: DatasetContext
Returns MaybePromise<number>
key
read
-
a keyed read: the rows for these keys, omitting any that no longer exist; never a full load
Parameters
- ids: readonly string[]
- ctx: DatasetContext
Returns MaybePromise<readonly Row[]>
seed
-
seed(
ctx: DatasetSeedContext,
): MaybePromise<
| readonly Row[]
| Iterable<readonly Row[], any, any>
| AsyncIterable<readonly Row[], any, any>,
>Every row in ascending key order (code unit order), as an array or as pages of rows. With
ctx.afterset it may start after that key. It runs once to admit a seed and once per page.Parameters
- ctx: DatasetSeedContext
Returns MaybePromise<
| readonly Row[]
| Iterable<readonly Row[], any, any>
| AsyncIterable<readonly Row[], any, any>,
>
Properties
max Bytes
most bytes of row JSON a seed may hold
max Rows
most rows a seed may hold
Optionalmax Stale Ms
Principal datasets only, and required there: how long held rows may answer a query after the last sync that returned and verified. Past it the query goes to the network. It is also the longest a device keeps serving rows after the server stopped admitting its principal.
Optionalprovision
always (the default) answers every seed. auto answers a seed only while datasetBenefit
says the dataset beats both v0.3 and native HTTP; otherwise the seed is refused with 409.
schema
a version string for the row shape; a device holding another one reseeds
scope
public rows are the same for everyone. A principal dataset holds rows that differ per
signed-in principal; it needs maxStaleMs, defineDataset's principalDatasets option and
createSpool's principalDatasets flag. Unreviewed.
the declaration
defineDatasettakes