QueryStoreclass

new QueryStore<I, T>(collection: Collection<string, I, T>, query: Query<Item<I, T>>, provider: DBProvider<I>, memory?: MemoryDBProvider<I>)
ParamType
collectionCollection<string, I, T>
The collection the query runs against. required
queryQuery<Item<I, T>>
The query that selects the items to track. required
providerDBProvider<I>
The database provider to fetch the items from. required
memoryMemoryDBProvider<I>
Optional memory provider used to seed the initial value and drive realtime updates.
Return
QueryStore<I, T>
Store that runs a query against a collection from a database provider and tracks its matching items.
PropertyType
.providerDBProvider<I>
The database provider this store fetches its items from. required readonly
.collectionCollection<string, I, T>
The collection the query runs against. required readonly
.queryQuery<Item<I, T>>
The query that selects the items tracked by this store. required readonly
.limitnumber
The maximum number of items the query can return, or Infinity if unlimited. required readonly
.hasMoreboolean
Whether more items can be loaded after the current result. required readonly
.optionalFirstItem<I, T>
The first item in this store, or undefined if the query has no items. readonly
.optionalLastItem<I, T>
The last item in this store, or undefined if the query has no items. readonly
.firstItem<I, T>
The first item in this store. required readonly
.lastItem<I, T>
The last item in this store. required readonly

Store that runs a query against a collection from a database provider and tracks its matching items.

  • Holds an Items value (the array of matching items) and is iterable over those items.
  • Seeds from a MemoryDBProvider snapshot when available, and subscribes to realtime updates.

Examples

const store = new QueryStore(collection, query, provider);
 for (const item of store) console.log(item);