Projecting Our Events
Since we’re recording all the changes to our system using events, we should use them not only for the commands (the write model) but also to do queries as well (the so-called read model). In this way, we can also get rid of the last “temporary hack,” namely, the ToDoListFetcherFromMap.
The question is, how can we query events? Since each event doesn’t contain the whole information of an entity but only what’s changed, it would be very hard to run queries directly on top of the event store.
What we’re going to do instead is project the events in a stateful data structure that we can query like it was a database table. Even better, we can create multiple projections with different properties, depending on our needs.
Projections ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access