import type { RxDocumentData, RxJsonSchema, RxStorageStatics, FilledMangoQuery, DefaultPreparedQuery} from 'nxdb-old/src/types'; import { newRxError } from 'nxdb-old/src/rx-error'; import { getQueryPlan } from 'nxdb-old/src/query-planner'; import { DEFAULT_CHECKPOINT_SCHEMA } from 'nxdb-old/src/rx-schema-helper'; /** * Most RxStorage implementations use these static functions. * But you can use anything that implements the interface, * for example if your underlying database already has a query engine. */ export const RxStorageDefaultStatics: RxStorageStatics = { prepareQuery( schema: RxJsonSchema>, mutateableQuery: FilledMangoQuery ): DefaultPreparedQuery { if (!mutateableQuery.sort) { throw newRxError('SNH', { query: mutateableQuery }); } /** * Store the query plan together with the * prepared query to save performance. */ const queryPlan = getQueryPlan( schema, mutateableQuery ); return { query: mutateableQuery, queryPlan }; }, checkpointSchema: DEFAULT_CHECKPOINT_SCHEMA };