UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

34 lines (33 loc) 1.68 kB
import { FetchStore } from "../../store/FetchStore.js"; import type { Data } from "../../util/data.js"; import type { Identifier, Item, Items } from "../../util/item.js"; import { type Query } from "../../util/query.js"; import type { Collection } from "../collection/Collection.js"; import type { DBProvider } from "../provider/DBProvider.js"; import type { MemoryDBProvider } from "../provider/MemoryDBProvider.js"; /** Store that queries multiple items in a collection from a database provider. */ export declare class QueryStore<I extends Identifier, T extends Data> extends FetchStore<Items<I, T>> implements Iterable<Item<I, T>> { readonly provider: DBProvider<I>; readonly collection: Collection<string, I, T>; readonly query: Query<Item<I, T>>; get limit(): number; /** Can more items be loaded after the current result. */ get hasMore(): boolean; private _hasMore; /** Get the first item in this store or `null` if this query has no items. */ get optionalFirst(): Item<I, T> | undefined; /** Get the last item in this store or `null` if this query has no items. */ get optionalLast(): Item<I, T> | undefined; /** Get the first item in this store. */ get first(): Item<I, T>; /** Get the last item in this store. */ get last(): Item<I, T>; constructor(collection: Collection<string, I, T>, query: Query<Item<I, T>>, provider: DBProvider<I>, memory?: MemoryDBProvider<I>); _fetch(_signal: AbortSignal): Promise<Items<I, T>>; /** * Load more items after the last once. * - Promise that needs to be handled. * @todo Make this work. */ [Symbol.iterator](): Iterator<Item<I, T>>; }