Skip to content

EventStore

Paul Grimshaw edited this page Feb 28, 2025 · 3 revisions

Querying events

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)
}

Appending events

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.

Clone this wiki locally