-
Notifications
You must be signed in to change notification settings - Fork 2
es cqrs.Repository
es-cqrs.Repository
An aggregate repository is a storage handler for aggregates. It recreates an aggregate every time from the event store, but to speed things up, it first tries to load up a snapshot of the aggregate. It is also responsible for persisting the aggregate by saving its events.
Typeparam
T an Aggregate
| Name | Type |
|---|---|
T |
extends Aggregate
|
• Private Readonly aggregateType: AggregateConstructor<T>
packages/es-cqrs/src/repository.ts:27
• Private Readonly eventStore: EventStoreProvider
packages/es-cqrs/src/repository.ts:29
• Private Readonly publisher: EventPublisher<Event>
packages/es-cqrs/src/repository.ts:28
▸ find(id, userId?): Promise<T>
Recreate an aggregate from the events
| Name | Type | Description |
|---|---|---|
id |
string |
aggregate id |
userId? |
string |
user id for subsequent operations, can be omitted for reading |
Promise<T>
an aggregate
packages/es-cqrs/src/repository.ts:43
▸ persist(aggregate): Promise<void>
Persist an aggregate by saving its events
| Name | Type |
|---|---|
aggregate |
T |
Promise<void>