UNPKG

@codai/cbd

Version:

Codai Better Database - High-Performance Vector Memory System with HPKV-inspired architecture and MCP server

122 lines 3.47 kB
/** * Document Storage Engine - MongoDB-compatible document database * Part of CBD Universal Database Phase 2 & 3 */ import { EventEmitter } from 'events'; export interface DocumentQuery { [key: string]: any; $and?: DocumentQuery[]; $or?: DocumentQuery[]; $not?: DocumentQuery; $eq?: any; $ne?: any; $gt?: any; $gte?: any; $lt?: any; $lte?: any; $in?: any[]; $nin?: any[]; $exists?: boolean; $regex?: string; $text?: { $search: string; }; } export interface DocumentUpdate { $set?: any; $unset?: any; $inc?: any; $push?: any; $pull?: any; $addToSet?: any; } export interface CollectionStats { name: string; count: number; size: number; avgObjSize: number; storageSize: number; indexCount: number; } export declare class DocumentStorageEngine extends EventEmitter { private collections; private indexes; constructor(); initialize(): Promise<void>; /** * Insert a single document */ insertDocument(collection: string, document: any): Promise<string>; /** * Insert a single document (MongoDB-compatible alias) */ insertOne(collection: string, document: any): Promise<string>; /** * Insert multiple documents */ insertMany(collection: string, documents: any[]): Promise<string[]>; /** * Find documents matching query */ findDocuments(collection: string, query?: DocumentQuery, options?: { limit?: number; skip?: number; sort?: Record<string, 1 | -1>; projection?: Record<string, 0 | 1>; }): Promise<any[]>; /** * Find documents (MongoDB-compatible alias) */ find(collection: string, query?: DocumentQuery, options?: { limit?: number; skip?: number; sort?: Record<string, 1 | -1>; projection?: Record<string, 0 | 1>; }): Promise<any[]>; /** * Find a single document */ findOne(collection: string, query?: DocumentQuery, options?: { projection?: Record<string, 0 | 1>; }): Promise<any | null>; /** * Update a single document */ updateDocument(collection: string, filter: DocumentQuery, update: DocumentUpdate): Promise<{ matchedCount: number; modifiedCount: number; }>; /** * Update a single document (MongoDB-compatible alias) */ updateOne(collection: string, filter: DocumentQuery, update: DocumentUpdate): Promise<{ matchedCount: number; modifiedCount: number; }>; /** * Delete documents matching filter */ deleteDocuments(collection: string, filter: DocumentQuery): Promise<number>; /** * Delete a single document */ deleteOne(collection: string, filter: DocumentQuery): Promise<number>; /** * Get collection statistics */ getCollectionStats(collection?: string): Promise<CollectionStats | null | Record<string, CollectionStats>>; private getOrCreateCollection; private generateId; private matchesQuery; private matchesFieldQuery; private applyUpdate; /** * Alias for insertDocument - Cloud service compatibility */ insert(collection: string, document: any): Promise<string>; /** * Find document by ID - Cloud service compatibility */ findById(collection: string, id: string): Promise<any | null>; } //# sourceMappingURL=DocumentStorageEngine.d.ts.map