disintegrate-es/disintegrate

Querying via event store

Closed this issue · 2 comments

Thanks for writing this library, I really like the look of it.

I am doing a proof-of-concept of using this library to manage state for turn-based games. When a client joins, I'd like to be able to send them a list of all events that have been persisted for a particular game.

In the courses example, querying seems to be implemented by going to the database directly rather than via the event store.

Do you have any plans to support querying events by domain entity via the event store so that the details of the event store implementation are abstracted?

Hi @dspasojevic,

Thank you for your feedback! Could you please provide more context on what you're trying to achieve? This will help us better understand if there's room for improvement in our API.

To access events through the event store, you can use the stream method of the EventStore. You can query EventStore like this:

event_store.stream(&query!(GameEvents, game_id == game_id)).await;

Or, if you're retrieving events from the last_seen_event_id:

event_store.stream(&query!(last_seen_event_id; GameEvents, game_id == game_id)).await;

Let us know if this answer your question.

I'll close this issue due to inactivity. @dspasojevic, if you need further insights, please let us know.