QueryStoreclass
new QueryStore<I, T>(collection: Collection<string, I, T>, query: Query<Item<I, T>>, provider: DBProvider<I>, memory?: MemoryDBProvider<I>)
| Param | Type | |
|---|---|---|
collection | Collection<string, I, T> | The collection the query runs against. required |
query | Query<Item<I, T>> | The query that selects the items to track. required |
provider | DBProvider<I> | The database provider to fetch the items from. required |
memory | MemoryDBProvider<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. |
| Property | Type | |
|---|---|---|
.provider | DBProvider<I> | The database provider this store fetches its items from. required readonly |
.collection | Collection<string, I, T> | The collection the query runs against. required readonly |
.query | Query<Item<I, T>> | The query that selects the items tracked by this store. required readonly |
.limit | number | The maximum number of items the query can return, or Infinity if unlimited. required readonly |
.hasMore | boolean | Whether more items can be loaded after the current result. required readonly |
.optionalFirst | Item<I, T> | The first item in this store, or undefined if the query has no items. readonly |
.optionalLast | Item<I, T> | The last item in this store, or undefined if the query has no items. readonly |
.first | Item<I, T> | The first item in this store. required readonly |
.last | Item<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
Itemsvalue (the array of matching items) and is iterable over those items. - Seeds from a
MemoryDBProvidersnapshot when available, and subscribes to realtime updates.
Examples
const store = new QueryStore(collection, query, provider); for (const item of store) console.log(item);