/** * MongoDB Adapter * * Database adapter for MongoDB databases using the 'mongodb' driver. * Implements all methods from BaseAdapter with MongoDB-specific operations. * * Note: MongoDB uses collections instead of tables, and documents instead of rows. * The adapter translates SQL-like operations to MongoDB operations. */ import { BaseAdapter, DatabaseFeature } from './base.adapter'; import { DatabaseType, IsolationLevel } from '../types/enums'; import { IAdapterConnectionOptions, IAdapterConnectionResult } from '../types/connection.interface'; import { IQueryResult, IRawQueryOptions, IRawQueryResult, IBuiltQuery } from '../types/query.interface'; import { IInsertOptions, IInsertResult, IUpdateOptions, IUpdateResult, IDeleteOptions, IDeleteResult, IUpsertOptions, IUpsertResult } from '../types/write.interface'; import { ITransactionContext, ISavepoint } from '../types/transaction.interface'; import { ICountOptions, ISumOptions, IAvgOptions, IMinMaxOptions, IAggregateResult, IGroupByResult, IBuiltAggregation } from '../types/aggregation.interface'; import { ITableDefinition, IAlterTableOperation, ITableSchema, ITableInfo, IIndexDefinition, IIndexInfo, IIndexStatistics, ICreateTableOptions } from '../types/schema.interface'; /** * MongoDB database adapter * Provides MongoDB-specific implementations for all database operations */ export declare class MongoDBAdapter extends BaseAdapter { protected readonly databaseType = DatabaseType.MONGODB; private mongoClient; private db; private databaseName; connect(options: IAdapterConnectionOptions): Promise; testConnection(options: IAdapterConnectionOptions): Promise; disconnect(): Promise; query(query: IBuiltQuery): Promise>; raw(options: IRawQueryOptions): Promise>; insert(options: IInsertOptions): Promise>; update(options: IUpdateOptions): Promise>; delete(options: IDeleteOptions): Promise; upsert(options: IUpsertOptions): Promise>; count(options: ICountOptions): Promise; sum(options: ISumOptions): Promise; avg(options: IAvgOptions): Promise; min(options: IMinMaxOptions): Promise; max(options: IMinMaxOptions): Promise; aggregate(builtAggregation: IBuiltAggregation): Promise; groupBy(builtGroupBy: IBuiltAggregation): Promise[]>; beginTransaction(isolationLevel?: IsolationLevel, readOnly?: boolean, timeout?: number): Promise; commitTransaction(context: ITransactionContext): Promise; rollbackTransaction(context: ITransactionContext): Promise; createSavepoint(context: ITransactionContext, name: string): Promise; releaseSavepoint(context: ITransactionContext, savepoint: ISavepoint): Promise; rollbackToSavepoint(context: ITransactionContext, savepoint: ISavepoint): Promise; supportsSavepoints(): boolean; createTable(definition: ITableDefinition, options?: ICreateTableOptions): Promise; /** * Register an auto-increment field in the counters collection. * This creates/updates the counter document for the given collection and field. */ private registerAutoIncrementField; /** * Get the next auto-increment value atomically. * Uses findOneAndUpdate with $inc to ensure atomic increment even under high concurrency. */ private getNextAutoIncrementValue; /** * Get all auto-increment fields for a collection from the counters collection. */ private getAutoIncrementFields; /** * Store schema metadata for a collection (including default values). * MongoDB doesn't have native schema enforcement, so we store this for application-level use. */ private storeSchemaMetadata; /** * Get schema metadata for a collection to apply defaults during insert. */ private getSchemaMetadata; /** * Resolve a default value to its actual value. * Handles special values like 'now', 'NOW()', true, false, etc. */ private resolveDefaultValue; /** * Generate a UUID v4. */ private generateUUID; alterTable(tableName: string, operations: IAlterTableOperation[]): Promise; dropTable(tableName: string, ifExists?: boolean, cascade?: boolean): Promise; listTables(): Promise; listTablesWithInfo(): Promise; tableExists(tableName: string): Promise; getTableSchema(tableName: string): Promise; createIndex(index: IIndexDefinition, ifNotExists?: boolean, concurrent?: boolean): Promise; dropIndex(tableName: string, indexName: string, ifExists?: boolean, concurrent?: boolean, cascade?: boolean): Promise; listIndexes(tableName: string, includeSystem?: boolean): Promise; getIndexStatistics(tableName: string, indexName?: string): Promise; escapeIdentifier(identifier: string): string; escapeValue(value: any): string; /** * Check if value is an update operator object * Supports both lowercase (new) and uppercase (legacy) operators */ private isUpdateOperator; getParameterPlaceholder(index: number): string; getColumnTypeString(columnType: string, options?: { minLength?: number; maxLength?: number; precision?: number; scale?: number; enumValues?: string[]; arrayType?: string; }): string; getSupportedFeatures(): DatabaseFeature[]; parseError(error: any): { type: string; message: string; code?: string; details?: Record; }; private ensureConnected; private buildMongoFilter; private extractFieldTypes; private getJsType; private formatBytes; }