How to find an event in EventStore by it Id?

1.9k Views Asked by At

Currently I'm using Eventstore (by Greg Young) for my company project. In my read model, I store the processed event ids, not the event name. How can I find the event in Eventstore using its Id?

2

There are 2 best solutions below

2
On

You can query the event using the following URL path. This will return the event and the last 20 events before it

{youreventstoredomain}:2113/web/index.html#/streams/$ce-{streamname}/{eventnumber}/backward/20

1
On

I don't think this is possible currently. I think you have two choices:

in your read model store the stream and index, or the commit/prepare position of the event and then read the event from either the $all stream using the commit/prepare position or from the stream it was written to using the stream and index. This is probably the simplest.

Or create a projection in event store which indexes the events by their id and reprojects into a stream called, say, eventid-{event.id} then you can read directly from this stream.

The second is backwards compatible with your current read model, but I'm not sure is the right thing to do, as projections cause write amplification, and you probably need to make sure you exclude system events from being projected.