@mocanvas/store · class
declare class StoreQueries<R extends UnknownRecord>This one ships without a description. The signature above is read from the package, and the guides cover the area it belongs to.
Methods · 6
constructor(store: Store<R, any>)exec<T extends R["typeName"]>(typeName: T, filter: StoreQueryFilter<RecordFromTypeName<R, T>>): RecordFromTypeName<R, T>[]Non-reactive filter over the records of typeName.
filterHistory<T extends R["typeName"]>(typeName: T): Computed<number, RecordsDiff<RecordFromTypeName<R, T>>>The store's history, narrowed to one record type.
Its *value* is only a counter — what it is for is the diffs it carries.
filterHistory("shape").getDiffSince(epoch) is every change to shapes
since epoch, with changes to other record types dropped, which is how a
derived collection stays incremental without re-reading the store.
ids<T extends R["typeName"]>(typeName: T, filter?: StoreQueryFilter<RecordFromTypeName<R, T>>): Computed<ReadonlySet<IdOf<RecordFromTypeName<R, T>>>>The set of ids of every record of typeName, optionally narrowed by a
filter. Maintained incrementally.
record<T extends R["typeName"]>(typeName: T, filter?: StoreQueryFilter<RecordFromTypeName<R, T>>): Computed<RecordFromTypeName<R, T> | undefined>The first record of typeName matching filter (or the first record, when omitted).
records<T extends R["typeName"]>(typeName: T, filter?: StoreQueryFilter<RecordFromTypeName<R, T>>): Computed<RecordFromTypeName<R, T>[]>Every record of typeName, in insertion order, optionally narrowed by a
filter.
A QueryExpression with an eq clause is answered from the index on
that property, so a page with ten thousand shapes does not have to be
walked to find the twelve on one frame.
Properties · 1
index<T extends R["typeName"], Property extends keyof RecordFromTypeName<R, T> & string>(typeName: T, property: Property): RSIndex<RecordFromTypeName<R, T>, Property>A live index from the values of one property to the ids of the records holding them.
The index is cached per type and property, and it carries diffs: a
dependent that already built something from it can ask
index.getDiffSince(epoch) and patch, instead of walking the whole map
again. That is what makes "every shape whose parentId is this frame" cheap
enough to recompute on every pointer move.
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.