Optional
query: ComplexQueryExpressiona complex query expression
Optional
options: ComplexQueryOptions & SortOptions & PaginationOptionscomplex query, sort and paginate options.
A function which filters, sorts and paginates the given query result.
import { createComplexQueryEngine } from "store-api/utils";
import { AsyncStore, ComplexQueryExpression, QueryOptions } from "./api";
type MyItemType = Record<string, any>;
class MyStore implements AsyncStore<MyItemType> {
items: MyItemType[] = [{ a: 1 }, { b: 2 }];
async query(complexQuery?: ComplexQueryExpression, options?: QueryOptions) {
// filter, sort, paginate the items array
return createComplexQueryEngine(complexQuery, options)(this.items);
}
}
This function creates a new function which can be used to implement a Store.query method by evaluating and filtering data available in an iterable, e.g. array.