ZfaStore class
A generic, reflection-free entity store keyed by principal key (v8, ZFA-008).
ZfaStore resolves every entity's metadata — principal key, diff, patch,
wire codec, fields — through a ZfaTypeRegistry of generated
ZorphyEntityDescriptors, so it stores any registered entity type without a
runtimeType switch. It owns an in-memory index of ZfaDocuments and the
three operations the v8 surfaces need: upsert, applyPatch, and the
optimistic preview overlay.
Identity is structured, never stringified (issue #2223): the outer index is
keyed by the entity's Type and each per-type bucket is keyed by the
original principal-key object, so two same-named types from different
libraries and two keys with the same toString() stay distinct documents.
final store = ZfaStore(registry: registry);
store.upsert(product);
final draft = store.preview('sku-1', ProductPatch(...));
final cheap = store.query(ZfaQuery<Product>(
where: [ProductFields.price.lessThan(100)],
));
Constructors
- ZfaStore({required ZfaTypeRegistry registry})
-
Creates a store backed by
registry.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
applyPatch<
T extends ZorphyEntityBase< (Object?> >Object key, ZorphyPatch< T> patch) → ZfaDocument<T> -
Applies
patchto the stored entitykey, returning the updated document. -
backend<
T extends ZorphyEntityBase< (Object?> >) → ZfaBackend< T> -
A mock-first partition over this store for entity type
T(v8, ZFA-014). -
get<
T extends ZorphyEntityBase< (Object?> >Object key) → ZfaDocument< T> ? -
The document stored for
key, ornullwhen nothing is stored. -
keysOf<
T extends ZorphyEntityBase< (Object?> >) → Iterable< Object> -
Every original principal-key object currently stored for the entity type
T. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
preview<
T extends ZorphyEntityBase< (Object?> >Object key, ZorphyPatch< T> draftPatch) → ZfaDocument<T> -
Overlays
draftPatchon the stored entitykeywithout committing it, returning the optimistic ZfaDocument a view renders. -
query<
T extends ZorphyEntityBase< (Object?> >ZfaQuery< T> query) → List<ZfaDocument< T> > -
Every document matching
query, ordered by its ZfaQuery.orderBy. -
remove<
T extends ZorphyEntityBase< (Object?> >Object key) → bool -
Removes the document stored for
key, returning whether one was present. -
toString(
) → String -
A string representation of this object.
inherited
-
upsert<
T extends ZorphyEntityBase< (Object?> >T value) → ZfaDocument< T> -
Stores
value, returning the ZfaDocument it is indexed under. -
watch<
T extends ZorphyEntityBase< (Object?> >Object key, void onChanged()) → ZfaStoreSubscription -
Observes mutations of the document stored at
keyfor entity typeT.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited