Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find an event in EventStore by it Id?

Tags:

eventstoredb

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?

like image 438
ThieuND Avatar asked Oct 16 '22 10:10

ThieuND


1 Answers

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.

like image 176
Sam Holder Avatar answered Oct 21 '22 09:10

Sam Holder