-
Notifications
You must be signed in to change notification settings - Fork 1
EventStore
Paul Grimshaw edited this page Feb 28, 2025
·
3 revisions
The Event Store can be queried by event type and tags, e.g.:
const esQuery = { eventTypes: ["courseWasRegistered"], tags: ["courseId=1234"] }
for await (const eventEnvelope of eventStore.read(query)) {
console.log(eventEnvelope)
}
When event(s) are appended to the store, a second parameter, an AppendCondition can be supplied. This can contain an array of queries that were used to build any write models, as well as the last sequence number seen. This will ensure no new relevant events are added in a race condition that would invalidate the append.
This library is simply a few functions to simplify the management of these concepts, and it is best explained with some examples.