import { BehaviorSubject, Observable } from 'rxjs'; import type { RxCollection, RxDocument, RxQueryOP, RxQuery, MangoQuery, MangoQuerySortPart, MangoQuerySelector, PreparedQuery, FilledMangoQuery, RxDocumentWriteData, RxDocumentData, QueryMatcher, ModifyFunction, Reactified } from './types/index.d.ts'; import { RxQuerySingleResult } from './rx-query-single-result.ts'; export declare class RxQueryBase { op: RxQueryOP; mangoQuery: Readonly>; collection: RxCollection; other: any; id: number; /** * Some stats then are used for debugging and cache replacement policies */ _execOverDatabaseCount: number; /** * @performance * Use Date.now() instead of now() for creation time. * The monotonic uniqueness guarantee of now() is not needed here * since _creationTime is only used by the cache replacement policy * for rough lifetime comparisons. */ _creationTime: number; _lastEnsureEqual: number; uncached: boolean; _refCount$: BehaviorSubject | null; get refCount$(): BehaviorSubject; isFindOneByIdQuery: false | string | string[]; /** * Contains the current result state * or null if query has not run yet. */ _result: RxQuerySingleResult | null; constructor(op: RxQueryOP, mangoQuery: Readonly>, collection: RxCollection, other?: any); get $(): Observable; get $$(): Reactified; _latestChangeEvent: -1 | number; /** * ensures that the exec-runs * are not run in parallel */ _ensureEqualQueue: Promise; /** * Returns an observable that emits the results * This should behave like an rxjs-BehaviorSubject which means: * - Emit the current result-set on subscribe * - Emit the new result-set when an RxChangeEvent comes in * - Do not emit anything before the first result-set was created (no null) */ _$?: Observable; /** * set the new result-data as result-docs of the query * @param newResultData json-docs that were received from the storage */ _setResultData(newResultData: RxDocumentData[] | number | Map>): void; /** * executes the query on the database * @return results-array with document-data */ _execOverDatabase(rerunCount?: number): Promise<{ result: RxDocumentData[] | number; counter: number; }>; /** * Execute the query * To have an easier implementations, * just subscribe and use the first result */ exec(throwIfMissing: true): Promise>; exec(): Promise; /** * Returns the normalized query. * Caches the result so that multiple calls to * queryMatcher, toString() and getPreparedQuery() * do not have to run the normalization again. * @overwrites itself with the actual value. */ get normalizedQuery(): FilledMangoQuery; /** * cached call to get the queryMatcher * @overwrites itself with the actual value */ get queryMatcher(): QueryMatcher>; /** * returns a string that is used for equal-comparisons * @overwrites itself with the actual value */ toString(): string; /** * returns the prepared query * which can be sent to the storage instance to query for documents. * @overwrites itself with the actual value. */ getPreparedQuery(): PreparedQuery; /** * returns true if the document matches the query, * does not use the 'skip' and 'limit' */ doesDocumentDataMatch(docData: RxDocType | any): boolean; /** * deletes all found documents * @return promise with deleted documents */ remove(throwIfMissing?: boolean): Promise; incrementalRemove(): Promise; /** * helper function to transform RxQueryBase to RxQuery type */ get asRxQuery(): RxQuery; /** * updates all found documents * @overwritten by plugin (optional) */ update(_updateObj: any): Promise; patch(patch: Partial): Promise; incrementalPatch(patch: Partial): Promise; modify(mutationFunction: ModifyFunction): Promise; incrementalModify(mutationFunction: ModifyFunction): Promise; where(_queryObj: MangoQuerySelector | keyof RxDocType | string): RxQuery; sort(_params: string | MangoQuerySortPart): RxQuery; skip(_amount: number | null): RxQuery; limit(_amount: number | null): RxQuery; } export declare function _getDefaultQuery(): MangoQuery; /** * run this query through the QueryCache */ export declare function tunnelQueryCache(rxQuery: RxQueryBase): RxQuery; export declare function createRxQuery(op: RxQueryOP, queryObj: MangoQuery, collection: RxCollection, other?: any): RxQueryBase; /** * Runs the query over the storage instance * of the collection. * Does some optimizations to ensure findById is used * when specific queries are used. */ export declare function queryCollection(rxQuery: RxQuery | RxQueryBase): Promise<{ docs: RxDocumentData[]; /** * We need to remember the counter directly here * because getting if after the returned Promise is resolved, * can result in a value that no longer matches the result set. */ counter: number; }>; /** * Returns true if the given query * selects documents by primary key using $eq or $in. * Used to optimize performance: these queries use get-by-id * instead of a full index scan. Additional operators beyond * $eq/$in are handled via the queryMatcher after fetching. * Skip, limit, and sort are also applied after fetching. * Returns false if no such optimization is possible. * Returns the document id (string) or ids (string[]) otherwise. */ export declare function isFindOneByIdQuery(primaryPath: string, query: MangoQuery): false | string | string[]; export declare function isRxQuery(obj: any): boolean;