Interface: EntryStore<TProps>
Defined in: model/dataset.ts:42
The Dataset's entries, read and write — dataset.entries.add/update/remove. Each
mutator returns the entry as the store holds it after the call (branded id, resolved instants),
never the input, and each auto-wraps itself in a transaction when none is already open.
load, syncAll and syncChanges are the three exceptions to both: each returns void, and
each refuses an open transaction (TransactionAlreadyOpenError) rather than join one — see their
own comments below.
Extends
EntryStoreView<TProps>
Type Parameters
TProps
TProps = Record<string, unknown>
Properties
all
readonlyall: readonlyEntry<TProps>[]
Defined in: model/dataset.ts:22
Inherited from
size
readonlysize:number
Defined in: model/dataset.ts:25
Inherited from
storedValues
readonlystoredValues:ReadonlyMap<EntryId,StoredEntry<TProps>>
Defined in: model/dataset.ts:33
The committed rows as stored values, keyed by id — what the edit pipeline carries (ADR
0017, P4). A drag preview hands this straight to the extension hook as EditRequest.entries,
which is committed-only by contract. One map identity per commit, so a frame that
reads it allocates nothing (I5).
A reader asking what a row is worth now wants get(id) and the live Entry. This door
exists for the one caller that must not read now: a cascade computing a delta.
Inherited from
Methods
add()
add(
input):Entry<TProps>
Defined in: model/dataset.ts:55
Declared Field keys sit flat at the top, the same shape update() takes (ADR 0011):
entries.add({ id, name, owner: 'Ali' }). Nested props stays legal for a bag already held or
a passenger key — naming one both there and at the top throws.
Typed as EntryIngestInput<TProps> (#281, #527), not the & Partial<TProps> intersection an
earlier draft first suggested — that intersection is uninhabitable by a named
EntryInput<TProps>[] value once TProps defaults to an open record
(Partial<Record<string, unknown>> demands an index signature EntryInput does not carry),
which broke every fixture that pre-types its own array. EntryIngestInput's own comment
(stored-entry.ts) explains both halves of the union: the flat-key check FlatEntryInput runs
for a concrete TProps, and the plain EntryInput<TProps> a caller generic over TProps must
fall back to, since FlatEntryInput<TProps> does not resolve for it.
Parameters
input
EntryIngestInput<TProps>
Returns
Entry<TProps>
get()
get(
id):Entry<TProps> |undefined
Defined in: model/dataset.ts:23
Parameters
id
string | EntryId
Returns
Entry<TProps> | undefined
Inherited from
has()
has(
id):boolean
Defined in: model/dataset.ts:24
Parameters
id
string | EntryId
Returns
boolean
Inherited from
load()
load(
inputs):void
Defined in: model/dataset.ts:79
A full fresh start (#496): replaces every Entry with inputs, in the list's own order — a
child may list before its parent, since the whole batch is checked before any of it stages
(DuplicateEntryIdError, EntryNotFoundError, or ParentCycleError for a bad one, and
nothing stages when one throws). For valid input, entries.all after load(inputs) reads the
same rows, in the same order, that new Dataset({ entries: inputs }) with this Dataset's own
Fields and plugins would build — but load writes onto the live Dataset a mounted Gantt already
holds, and it keeps no per-entry state (selection, collapse, a plugin's store row) for an id
both the old data and inputs name.
Commits one ChangeSet with origin: 'load', even when nothing changed — an empty load()
into an empty Dataset still moves the baseline. History clears on it: canUndo/canRedo
both read false right after, the same posture a desktop app takes opening a file. beforeChange
can still veto it (MutationCancelledError), leaving the store and History exactly as they were.
Ignores a 'never' Field lock and re-rolls a derived parent cell, the same as construction, and
runs no EditExtender cascade — construction runs none either. Refuses with
TransactionAlreadyOpenError when called inside dataset.transaction(): load is always its
own transaction.
The undoable, diffing counterpart that keeps per-entry state for a kept id is entries.syncAll()
(#517).
Parameters
inputs
readonly EntryIngestInput<TProps>[]
Returns
void
remove()
remove(
id):void
Defined in: model/dataset.ts:57
Parameters
id
string | EntryId
Returns
void
syncAll()
syncAll(
inputs):void
Defined in: model/dataset.ts:100
Matches a live Dataset to inputs by diffing instead of replacing (#517): an id the list omits
is removed, a key a kept entry's input omits is cleared, and a Field whose value did not change
writes no row. After syncAll(inputs), the entry ids, every declared Field value (siblingIndex
included) and the tree are the same as load(inputs) would leave — only History and per-entry
state differ. A kept id keeps its selection, its collapse state and its plugin store rows; a
removed id loses them, and an undo brings a removed id's store rows back with it. An undeclared
props key on a kept id is not written: declare the Field to sync it.
Writes through the same door load uses: it ignores a 'never' Field lock, a derived parent
cell re-rolls instead of taking an authored value, and no EditExtender cascade runs.
beforeChange can veto the whole call. Refuses with TransactionAlreadyOpenError inside
dataset.transaction(), MutationDuringExtensionHookError from the extension hook, and
MutationDuringNotificationError from inside a beforeChange or change handler.
Commits one ChangeSet with origin: 'sync'. Unlike a user edit, it records no undo step
and erases no Redo — the user's own earlier steps stay undoable across a poll. A sync that
changes nothing commits nothing: no beforeChange, no change, and no undo step — the common
case for a server poll that finds nothing new. A local edit the server has not seen is
overwritten, last write wins. An undo of that edit later keeps the server's value (see
docs/11-server-data.md).
Parameters
inputs
readonly EntryIngestInput<TProps>[]
Returns
void
syncChanges()
syncChanges(
delta):void
Defined in: model/dataset.ts:107
Applies only the rows a server changed, where syncAll takes the whole list. An upsert row
with a new id adds an entry. A row with a known id edits that entry: an omitted key keeps its
value, and undefined clears it. remove drops each id with its subtree and ignores an
unknown id. An id in both lists throws DuplicateEntryIdError, and nothing applies. Writes and
commits the way syncAll does, so a delta that changes nothing commits nothing (see
docs/11-server-data.md).
Parameters
delta
EntryDelta<TProps>
Returns
void
update()
update(
id,edit):Entry<TProps>
Defined in: model/dataset.ts:56
Parameters
id
string | EntryId
edit
EntryEdit<TProps>
Returns
Entry<TProps>