UNPKG

@andrejs1979/document

Version:

MongoDB-compatible document database for NoSQL

87 lines 3.29 kB
/** * NoSQL - Relationship Manager * Advanced relationship management for document collections */ import { Document, QueryFilter, FindOptions, Relationship, PopulateOptions, RelationshipResult, DocumentDatabaseConfig } from '../types'; import { DocumentStorage } from '../storage/document-storage'; /** * Manages relationships between documents across collections */ export declare class RelationshipManager { private storage; private config; private relationshipCache; private populateCache; constructor(storage: DocumentStorage, config: DocumentDatabaseConfig); /** * Define a relationship between collections */ defineRelationship(sourceCollection: string, targetCollection: string, relationship: Relationship): Promise<void>; /** * Remove a relationship definition */ removeRelationship(sourceCollection: string, targetCollection: string, localField: string): Promise<void>; /** * Populate document with related data */ populate<T extends Document>(collection: string, document: T, populateOptions: PopulateOptions | PopulateOptions[]): Promise<RelationshipResult<T>>; /** * Populate multiple documents */ populateMany<T extends Document>(collection: string, documents: T[], populateOptions: PopulateOptions | PopulateOptions[]): Promise<RelationshipResult<T>[]>; /** * Find documents with automatic population */ findWithPopulate<T extends Document>(collection: string, filter: QueryFilter, populateOptions: PopulateOptions | PopulateOptions[], findOptions?: FindOptions): Promise<RelationshipResult<T>[]>; /** * Create document with relationship validation */ createWithRelationships(collection: string, document: Document): Promise<Document>; /** * Update document with relationship validation */ updateWithRelationships(collection: string, filter: QueryFilter, update: any): Promise<void>; /** * Delete document with relationship cleanup */ deleteWithRelationships(collection: string, filter: QueryFilter): Promise<void>; /** * Get relationship statistics */ getRelationshipStats(collection: string): Promise<{ totalRelationships: number; outgoingRelationships: number; incomingRelationships: number; relationshipTypes: Record<string, number>; }>; private populateField; private getRelationship; private validateDocumentRelationships; private updateReverseRelationships; private updateArrayRelationship; private handleCascadeDelete; private getOutgoingRelationships; private getIncomingRelationships; private validateRelationship; private storeRelationshipMetadata; private removeRelationshipMetadata; private loadRelationshipFromDatabase; private loadRelationshipsFromDatabase; private getRelationshipKey; private getPopulateCacheKey; private getFieldValue; private buildProjection; private applyUpdateToDocument; /** * Clear populate cache */ clearPopulateCache(): void; /** * Get populate cache statistics */ getPopulateCacheStats(): { size: number; memoryUsage: number; }; } //# sourceMappingURL=relationship-manager.d.ts.map