SnapshotMongoDBStorage

Hierarchy

  • SnapshotMongoDBStorage

Implements

Index

Methods

Methods

findById

findById(EventSourceableType: EventSourceableType, eventSourceableId: string | Guid): Promise‹EventSourceable | undefined›

Implementation of SnapshotStorage

Returns snapshot from Mongo snapshots collection by id if exists.

async

Parameters:

NameTypeDescription
EventSourceableTypeEventSourceableTypeEvent sourceable type(constructor).
eventSourceableIdstring | GuidIdentifier as string or Guid instance.

Returns: Promise‹EventSourceable | undefined›

Instance as a snapshot implementing EventSourceable interface, else undefined.


save

save(eventSourceable: EventSourceable): Promise‹string›

Implementation of SnapshotStorage

Adds new snapshot as serialized version of EventSourceable instance to MongoDB snapshots collection.

async

Parameters:

NameTypeDescription
eventSourceableEventSourceableInstance implementing EventSourceable interface.

Returns: Promise‹string›

Identifier for document(as Snapshot's id) on MongoDB collection.


update

update(eventSourceable: EventSourceable): Promise‹boolean›

Updates EventSourceable snapshot on the snapshots collection.

async

throws {UpdatingSnapshotError} Thrown if update operation on MongoDB is not successful.

Parameters:

NameTypeDescription
eventSourceableEventSourceableInstance implementing EventSourceable interface.

Returns: Promise‹boolean›

Returns true if snapshot update was successful, else throws.