ReadonlyarchetypesReadonlycomponentDeletes the entity. Returns the entity that was swap-moved into the
vacated row (a relocation side effect), or undefined when the deleted
row was the last row. The return is optional info — callers that don't
track relocations may ignore it.
ReadonlyindexesIndex handles keyed by user-chosen name. Returned handles are the same references at the Store layer and the Database layer; mutations to the store keep them in sync as a side effect of every insert/update/delete.
ReadonlyresourcesOptionalundoableThis is used when a store is used to represent a transaction. For most stores, this is ignored if it is set.
Updates the entity. When the update migrates the entity to another
archetype, its old archetype swap-moves a neighbor into the vacated row;
that neighbor is returned (or undefined for an in-place update with no
migration). The migrated entity's own relocation is observable via
locate. The return is optional info — callers may ignore it.
Optional ReadonlyuserThe user on whose behalf the current transaction is running, set by
the dispatcher for the duration of a transaction body and undefined
otherwise. A store is the context a transaction operates on; there is
no separate transaction-context type.
Count the entities select would return for the same arguments — without building
an entity array. With no where filter it sums matched archetype row counts
(O(matched archetypes)); order is ignored (irrelevant to a count).
Optionaloptions: EntitySelectOptions<Restore from a snapshot. With no scope, performs a whole-database load
(restores both persistent quadrants and resets the non-persistent ones).
With a scope, restores only the in-scope persistent quadrant(s) and
leaves every other quadrant untouched (see PersistenceScope).
Optionalscope: PersistenceScopeConform the store's DATA to a target schema: keep is the set of
component + resource names to retain (the ECS built-ins are always kept).
Every other component is stripped from every entity — an entity keeping at
least one component migrates to its reduced archetype; an all-foreign
entity (including a foreign resource singleton) is removed. Prunes data
only: the emptied foreign archetypes and their unused schemas are shed on
the next fromData, not by an in-place structural rebuild. Prefer
Database.pruneToPluginSchema to derive keep from a plugin.
Optionaloptions: ArchetypeQueryOptions<C, PK>Read exactly the components of archetype. A membership GATE: returns
null unless the entity is a superset of archetype. The result is
narrowed to the archetype's own row — reading a component outside
archetype off the result is a compile error (use a wider archetype, the
component-list overload, or read(entity)).
Read a chosen subset of an entity's components.
A pure PROJECTION, not a membership gate: returns null only when the
entity does not exist. A requested component the entity does not have
comes back absent — the field stays optional in the result, exactly as
from the full read(entity).
Prefer this over read(entity) when only a few fields are needed: it
names the exact components touched, so db.derive can scope its
recompute to just those fields instead of the whole entity. id is not a
readable component (you already hold it); the element type is inferred as
a literal union.
Reconcile nonPersistent-schema columns after an external restore (e.g. a
persistence layer that rebuilt the store from disk column-by-column): reset
defaulted ones to their schema default and strip no-default ones (the entity
migrates out of the component). Idempotent. fromData already applies this
to its own loads; this is for callers that restore columns another way.
Wipe all entities and reset resources to plugin defaults. O(num_archetypes + num_resources).
Optionaloptions: EntitySelectOptions<Serialize the store to a plain snapshot. When copy is true the snapshot
is detached from the live store (column/entity buffers are copied) so it
remains valid after subsequent mutations; otherwise it references live
buffers and is only valid until the next mutation. See Database.toData()
for the bug this copy flag addresses for transient-bearing strategies.
options.scope selects which persistent quadrants to emit; omit for all.
Optionaloptions: ToDataOptions
Store is the main interface for storing components, entities and resources.