SnapshotMongoDBStorage
Hierarchy
- SnapshotMongoDBStorage
Implements
- SnapshotStorage
- SnapshotStorage
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:
Name | Type | Description |
---|---|---|
EventSourceableType | EventSourceableType | Event sourceable type(constructor). |
eventSourceableId | string | Guid | Identifier 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:
Name | Type | Description |
---|---|---|
eventSourceable | EventSourceable | Instance 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:
Name | Type | Description |
---|---|---|
eventSourceable | EventSourceable | Instance implementing EventSourceable interface. |
Returns: Promise‹boolean›
Returns true
if snapshot update was successful, else throws.