import type { Collection, UpdateFilter } from 'mongodb'; import { EventEmitter } from 'node:events'; import { MongoModel } from '../model/base_model.js'; import { ObjectId } from 'mongodb'; /** * MongoDB query builder class provides a fluent API to build * MongoDB queries. */ export declare class MongoQueryBuilder { private collection; private collectionName; private connectionName; private emitter; /** * Filter for the query */ private filter; /** * Sort options for the query */ private sortOptions; /** * Projection for the query */ private projection; /** * Limit for the query */ private limitValue; /** * Skip for the query */ private skipValue; /** * Model constructor */ private modelConstructor?; constructor(collection: Collection, collectionName: string, connectionName: string, emitter: EventEmitter, modelConstructor?: typeof MongoModel); /** * Clone the query builder */ clone(): MongoQueryBuilder; /** * Add a where clause to the query */ where(key: string, value: any): this; where(key: string, operator: string, value: any): this; where(key: Record): this; /** * Process MongoDB query object to handle RegExp objects */ private processMongoQuery; /** * Add a whereIn clause to the query */ whereIn(key: string, values: any[]): this; /** * Add a whereNotIn clause to the query */ whereNotIn(key: string, values: any[]): this; /** * Add a whereLike clause to the query */ whereLike(key: string, value: string): this; /** * Add a whereExists clause to the query */ whereExists(key: string, exists?: boolean): this; /** * Add a whereNull clause to the query */ whereNull(key: string): this; /** * Add a whereNotNull clause to the query */ whereNotNull(key: string): this; /** * Add an orWhere clause to the query */ orWhere(key: string, value: any): this; orWhere(key: string, operator: string, value: any): this; /** * Add a select clause to the query */ select(...fields: string[]): this; /** * Add an orderBy clause to the query */ orderBy(field: string, direction?: 'asc' | 'desc'): this; /** * Add a limit clause to the query */ limit(value: number): this; /** * Add a skip clause to the query */ offset(value: number): this; /** * Execute the query and return the first result */ first(): Promise; /** * Execute the query and return all results */ all(): Promise; /** * Execute the query and return the count */ count(): Promise; /** * Execute the query and return the results */ exec(): Promise; /** * Execute the query and update documents */ update(data: UpdateFilter): Promise; /** * Execute the query and delete documents */ delete(): Promise; /** * Execute the query and insert a document */ insert(data: Model): Promise; /** * Execute the query and insert multiple documents */ insertMany(data: Model[]): Promise; /** * Execute the query and paginate the results */ paginate(page?: number, perPage?: number): Promise<{ total: number; perPage: number; lastPage: number; page: number; data: Model[]; }>; /** * Execute an aggregation pipeline * * @param pipeline An array of aggregation pipeline stages * @returns The result of the aggregation pipeline */ aggregate(pipeline: any[]): Promise; }