import { ICollection , IDatabaseManager } from "./database" ; import { IDocument } from "./document" ; import { ISequencedOperationMessage } from "./messages" ; import { MongoManager } from "./mongo" ; import { INode } from "./orderer" ; /**
 * MongoDB implementation of IDatabaseManager
 */ export class MongoDatabaseManager implements IDatabaseManager { constructor ( private readonly mongoManager , private readonly nodeCollectionName , private readonly documentsCollectionName , private readonly deltasCollectionName , private readonly scribeDeltasCollectionName ) { } public async getNodeCollection ( ) { return this . getCollection < INode > ( this . nodeCollectionName ) ; } public async getDocumentCollection ( ) { return this . getCollection < IDocument > ( this . documentsCollectionName ) ; } public async getDeltaCollection ( tenantId , documentId ) { return this . getCollection < ISequencedOperationMessage > ( this . deltasCollectionName ) ; } public async getScribeDeltaCollection ( tenantId , documentId ) { return this . getCollection < ISequencedOperationMessage > ( this . scribeDeltasCollectionName ) ; } private async getCollection < T > ( name ) { const db = await this . mongoManager . getDatabase ( ) ; return db . collection < T > ( name ) ; } }