import { IDocument } from "./document" ; import { ISequencedOperationMessage } from "./messages" ; import { INode } from "./orderer" ; /**
 * Interface to abstract the backend database
 */ export interface IDatabaseManager { /**
     * Retrieves the node collection
     */ getNodeCollection ( ) : Promise < ICollection < INode > > ; /**
     * Retrieves the document collection
     */ getDocumentCollection ( ) : Promise < ICollection < IDocument > > ; /**
     * Retrieves the delta collection
     */ getDeltaCollection ( tenantId , documentId ) : Promise < ICollection < ISequencedOperationMessage > > ; /**
     * Scribe deltas collection
     */ getScribeDeltaCollection ( tenantId , documentId ) : Promise < ICollection < ISequencedOperationMessage > > ; } /**
 * Interface for a database of values that have type T.
 * In some implementations, T should have a member "_id" which is a string used
 * when adding or finding value in the database.
 */ export interface ICollection < T > { param pipeline param options returns aggregate ( group , options ? ) : any ; param query param sort returns find ( query , sort ) : Promise < T [ ] > ; param query returns findOne ( query ) : Promise < T > ; returns findAll ( ) : Promise < T [ ] > ; param query param value findOrCreate ( query , value ) : Promise < { value : T ; existing : boolean ; } > ; param filter param set param addToSet update ( filter , set , addToSet ) : Promise < void > ; param filter param set param addToSet updateMany ( filter , set , addToSet ) : Promise < void > ; param filter param set param addToSet upsert ( filter , set , addToSet ) : Promise < void > ; param value insertOne ( value ) : Promise < any > ; param values param ordered insertMany ( values , ordered ) : Promise < void > ; deleteOne ( filter ) : Promise < any > ; deleteMany ( filter ) : Promise < any > ; distinct ( key , query ) : Promise < any > ; createIndex ( index , unique ) : Promise < void > ; createTTLIndex ? ( index , mongoExpireAfterSeconds ? ) : Promise < void > ; }