/** * MongoDB 数据库适配器 * 使用 mongodb 驱动实现 DbAdapter 接口 * * 注意:MongoDB 是 NoSQL 文档数据库,没有固定的表结构 * 本适配器提供集合操作和文档查询功能 */ import type { DbAdapter, QueryResult, SchemaInfo } from '../types/adapter.js'; export declare class MongoDBAdapter implements DbAdapter { private client; private db; private config; constructor(config: { host: string; port: number; user?: string; password?: string; database?: string; authSource?: string; }); /** * 连接到 MongoDB 数据库 */ connect(): Promise; /** * 断开数据库连接 */ disconnect(): Promise; /** * 执行 MongoDB 查询 * * 支持的查询格式: * 1. JSON 格式的 MongoDB 查询: * {"collection": "users", "operation": "find", "query": {"age": {"$gt": 18}}} * 2. 简化的命令格式: * db.users.find({"age": {"$gt": 18}}) * 3. 聚合管道: * {"collection": "users", "operation": "aggregate", "pipeline": [...]} */ executeQuery(query: string, _params?: unknown[]): Promise; /** * 解析查询字符串 */ private parseQuery; /** * 执行 MongoDB 操作 */ private executeOperation; /** * 格式化 MongoDB 文档(将 ObjectId 转换为字符串) */ private formatDocument; /** * 获取 MongoDB 数据库信息 * * MongoDB 没有固定的表结构,这里通过采样文档来推断集合的字段 */ getSchema(): Promise; /** * 获取 MongoDB 值的类型 */ private getMongoType; /** * 检查是否为写操作 * * MongoDB 写操作包括:insert, update, delete, drop 等 */ isWriteOperation(query: string): boolean; /** * 检查操作名称是否为写操作 */ private isWriteOperationName; } //# sourceMappingURL=mongodb.d.ts.map