UNPKG

adonis-odm

Version:

A comprehensive MongoDB ODM for AdonisJS with Lucid-style API, type-safe relationships, embedded documents, and transaction support

156 lines 4.53 kB
import { QueryOperator, QueryValue } from '../types/index.js'; import type { NamingStrategyContract } from '../naming_strategy/naming_strategy.js'; import type { BaseModel } from '../base_model/base_model.js'; /** * WhereConditionsBuilder - Handles all WHERE clause construction for MongoDB queries * * This class encapsulates all the logic for building MongoDB filter conditions, * including AND, OR, NOT operations, and various comparison operators. */ export declare class WhereConditionsBuilder { private filters; private orConditions; private namingStrategy?; private modelClass?; constructor(namingStrategy?: NamingStrategyContract, modelClass?: typeof BaseModel); /** * Get the current filters */ getFilters(): any; /** * Get the current OR conditions */ getOrConditions(): any[]; /** * Set filters (used for cloning) */ setFilters(filters: any): void; /** * Set OR conditions (used for cloning) */ setOrConditions(conditions: any[]): void; /** * Convert field name to database column name using naming strategy */ private convertFieldName; /** * Recursively convert field names in a filter object */ private convertFilterFields; /** * Get the final MongoDB filter object */ getFinalFilters(): any; /** * Add a where condition */ where(field: string, value: QueryValue): this; where(field: string, operator: QueryOperator, value: QueryValue): this; /** * Alias for where method */ andWhere(field: string, value: QueryValue): this; andWhere(field: string, operator: QueryOperator, value: QueryValue): this; /** * Add a where not condition */ whereNot(field: string, value: QueryValue): this; whereNot(field: string, operator: QueryOperator, value: QueryValue): this; /** * Alias for whereNot method */ andWhereNot(field: string, operatorOrValue: QueryOperator | QueryValue, value?: QueryValue): this; /** * Add an OR where condition */ orWhere(field: string, operatorOrValue: QueryOperator | QueryValue, value?: QueryValue): this; /** * Add an OR where not condition */ orWhereNot(field: string, operatorOrValue: QueryOperator | QueryValue, value?: QueryValue): this; /** * Add a LIKE condition (case-sensitive) */ whereLike(field: string, value: string): this; /** * Add an ILIKE condition (case-insensitive) */ whereILike(field: string, value: string): this; /** * Add a NULL condition */ whereNull(field: string): this; /** * Add an OR NULL condition */ orWhereNull(field: string): this; /** * Add a NOT NULL condition */ whereNotNull(field: string): this; /** * Add an OR NOT NULL condition */ orWhereNotNull(field: string): this; /** * Add an EXISTS condition */ whereExists(field: string): this; /** * Add an OR EXISTS condition */ orWhereExists(field: string): this; /** * Add a NOT EXISTS condition */ whereNotExists(field: string): this; /** * Add an OR NOT EXISTS condition */ orWhereNotExists(field: string): this; /** * Add an IN condition */ whereIn(field: string, values: QueryValue[]): this; /** * Add an OR IN condition */ orWhereIn(field: string, values: QueryValue[]): this; /** * Add a NOT IN condition */ whereNotIn(field: string, values: QueryValue[]): this; /** * Add an OR NOT IN condition */ orWhereNotIn(field: string, values: QueryValue[]): this; /** * Add a BETWEEN condition */ whereBetween(field: string, range: [QueryValue, QueryValue]): this; /** * Add an OR BETWEEN condition */ orWhereBetween(field: string, range: [QueryValue, QueryValue]): this; /** * Add a NOT BETWEEN condition */ whereNotBetween(field: string, range: [QueryValue, QueryValue]): this; /** * Add an OR NOT BETWEEN condition */ orWhereNotBetween(field: string, range: [QueryValue, QueryValue]): this; /** * Map query operator to MongoDB operator */ private mapOperatorToMongo; /** * Serialize value for MongoDB */ private serializeValue; /** * Clone the where conditions builder */ clone(): WhereConditionsBuilder; } //# sourceMappingURL=where_conditions_builder.d.ts.map