import AnchoredOperationModel from './models/AnchoredOperationModel'; import IOperationStore from './interfaces/IOperationStore'; import NamedAnchoredOperationModel from './models/NamedAnchoredOperationModel'; /** * Implementation of OperationStore that stores the operation data in * a MongoDB database. */ export default class MongoDbOperationStore implements IOperationStore { private serverUrl; private collection; /** * MongoDb database name where the operations are stored */ private readonly databaseName; /** * MongoDB collection name under the database where the operations are stored */ private readonly operationCollectionName; constructor(serverUrl: string, databaseName?: string, operationCollectionName?: string); /** * Initialize the MongoDB operation store. */ initialize(): Promise; /** * Implement OperationStore.put */ put(operations: NamedAnchoredOperationModel[]): Promise; /** * Get an iterator that returns all operations with a given * didUniqueSuffix ordered by (transactionNumber, operationIndex) * ascending. */ get(didUniqueSuffix: string): Promise; /** * Delete all operations with transaction number greater than the * provided parameter. */ delete(transactionNumber?: number): Promise; /** * Convert a Sidetree operation to a more minimal IMongoOperation object * that can be stored on MongoDb. The IMongoOperation object has sufficient * information to reconstruct the original operation. */ private static convertToMongoOperation; /** * Convert a MongoDB representation of an operation to a Sidetree operation. * Inverse of convertToMongoOperation() method above. * * Note: mongodb.find() returns an 'any' object that automatically converts longs to numbers - * hence the type 'any' for mongoOperation. */ private static convertToAnchoredOperationModel; }