import { ModelAllListOptions } from "./interfaces/model.alllist.options.interface"; import { BaseModel } from "./base.model"; import type { QuerySnapshot, CollectionReference, DocumentData, FieldPath, Query as FirestoreQuery, OrderByDirection, WhereFilterOp } from "firebase/firestore"; export declare enum LIST_EVENTS { REMOVED = "removed", MODIFIED = "modified", ADDEDD = "added", INITIALIZE = "init" } export declare enum WHERE_FILTER_OP { NOT_EQUAL = "<>" } /** * Represents a query for retrieving documents from a Firestore collection. * @template T The type of the documents returned by the query. */ export declare class Query { protected current: CollectionReference; protected model: BaseModel; protected queryList: any[]; protected whereList: any[]; protected orWhereList: any[]; protected orderByList: any[]; protected ops: any[]; protected startAfterArr: BaseModel[]; protected endBeforeArr: BaseModel[]; protected queryLimit: number; protected currentRef: CollectionReference; protected isCollectionGroup_: boolean; init(model: BaseModel, reference?: FirestoreQuery | any, isCollectionGroup?: boolean): void; /** * Sets whether the query is targeting a collection group. * * @param isCollectionGroup - A boolean value indicating whether the query is targeting a collection group. * @returns The updated Query object. */ setCollectionGroup(isCollectionGroup: boolean): this; /** * Creates and returns a new Query with the additional filter that documents * must contain the specified field and the value should satisfy the * relation constraint provided. * * @param fieldPath The path to compare * @param opStr The operation string (e.g "<", "<=", "==", ">", ">=", "!="). * @param value The value for comparison * @return The created Query. */ where(fieldPath: string | FieldPath, opStr: WhereFilterOp | WHERE_FILTER_OP, value: any): Query; /** * Test Mode - Or operation for additional filter that documents * must contain the specified field and the value should satisfy the * relation constraint provided. * * @param fieldPath The path to compare * @param opStr The operation string (e.g "<", "<=", "==", ">", ">=", "!="). * @param value The value for comparison * @return The created Query. */ orWhere(fieldPath: string | FieldPath, opStr: WhereFilterOp | WHERE_FILTER_OP, value: any): Query; /** * Creates and returns a new Query that's additionally sorted by the * specified field, optionally in descending order instead of ascending. * * @param fieldPath The field to sort by. * @param directionStr Optional direction to sort by (`asc` or `desc`). If * not specified, order will be ascending. * @return The created Query. */ orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): Query; /** * Creates and returns a new Query where the results are limited to the * specified number of documents. * * @param limit The maximum number of items to return. * @return The created Query. */ limit(val: number): Query; like(fieldName: string, find: string): Query; /** * Attaches a listener for QuerySnapshot events. You may either pass * individual `onNext` and `onError` callbacks or pass a single observer * object with `next` and `error` callbacks. The listener can be cancelled by * calling the function that is returned when `onSnapshot` is called. * * NOTE: Although an `onCompletion` callback can be provided, it will * never be called because the snapshot stream is never-ending. * * @param callback A single object containing `next` and `error` callbacks. * @return An unsubscribe function that can be called to cancel * the snapshot listener. */ on(callback: CallableFunction, event_type?: LIST_EVENTS): CallableFunction; /** * Attaches a listener for QuerySnapshot events. You may either pass * individual `onNext` and `onError` callbacks or pass a single observer * object with `next` and `error` callbacks. The listener can be cancelled by * calling the function that is returned when `onSnapshot` is called. * * NOTE: Although an `onCompletion` callback can be provided, it will * never be called because the snapshot stream is never-ending. * * @param callback A single object containing `next` and `error` callbacks. * @return An unsubscribe function that can be called to cancel * the snapshot listener. */ onMode(options: ModelAllListOptions): CallableFunction; /** * Creates and returns a new Query that starts at the provided fields * relative to the order of the query. The order of the field values * must match the order of the order by clauses of the query. * * @param fieldValues The field values to start this query at, in order * of the query's order by. * @return The created Query. */ startAt(...fieldValues: any[]): Query; /** * Creates and returns a new Query that starts after the provided document * (exclusive). The starting position is relative to the order of the query. * The document must contain all of the fields provided in the orderBy of * this query. * * @param snapshot The snapshot of the document to start after. * @return The created Query. */ startAfter(ormObject: BaseModel): Query; initStartAfter(): Promise; /** * Creates and returns a new Query that ends before the provided fields * relative to the order of the query. The order of the field values * must match the order of the order by clauses of the query. * * @param fieldValues The field values to end this query before, in order * of the query's order by. * @return The created Query. */ endBefore(ormObject: BaseModel): Query; initEndBefore(): Promise; /** * Creates and returns a new Query that ends at the provided fields * relative to the order of the query. The order of the field values * must match the order of the order by clauses of the query. * * @param fieldValues The field values to end this query at, in order * of the query's order by. * @return The created Query. */ endAt(...fieldValues: any[]): Query; /** * Executes the query and returns the results as a `QuerySnapshot`. * * @return A Promise that will be resolved with the results of the Query. */ get(): Promise>; getRowList(): Promise>; count(): Promise; getCurrentQueryArray(): Array; getFirestoreQuery(): FirestoreQuery; initBeforeFetch(): Promise; /** * Executes the query and returns the results as a `QuerySnapshot`. * @return A Promise that will be resolved with the results of the Query. */ getOne(): Promise; parse(list: any): any[]; parseFromData(data: any, id?: string): any; }