My application use CQRS architecture. Everything is performed through my aggregates, thus each user’s action is saved as an event in my event source store.
Now, I need a new form which shows the history of every action performed in my application, so what should I do ?
1 – Read the event store ? How ?
2 – Publish an event in each of my domain handler like “SavedToHistory(User user, Action action, DateTime date) then in my event handlers, store it in my read data model ?
Since the whole idea of CQRS is to have separation of reading and writing, and of storage (reading vs writing again), I think the most consistent action you can take is to write denormalized history data to the Read database and read it from there rather than trying to read it from the Event Store.
This can be straightforward; you can write a general denormalizer that can write any new event in the Event Store to a denormalized version in the Read database, or you can have specialized denormalizers — it depends on how you want to display history in your application.
Either way, write denormalized versions of your events to the Read DB so that your application will not need to know exactly how events are structured in the Event Store.