Closed jaduff closed 6 years ago
Display should use the Read Model. Replaying for read is just a temporary hack.
Ah, I went back to an earlier conversation and found this:
"... in your case... can probably just read all the events from the db ... and build the read model each request ..."
Between the two, that answers my question. I could replay all events for the read model, but the recommended way is to store objects with a record of the latest event version it included, then replay any newer events to build up the read model. Then save the new read model back to the database.
I'll work on it (which it seems is what I said last time too!)
Now that there is a School aggregate root, / will only show a list of school, so only SchoolCreatedEvent, SchoolRenamedEvent, and later SchoolRemovedEvent will need to be replayed. Likewise, the / route will only show a list of Rooms, so would only need to replay RoomAddedEvent, RoomRenamed, and RoomDeleted, and only for the current school.
However, this will result in lots of chopping and changing code as additional events are created, rather than letting the replay handle it itself. Presumably the performance benefit is going to be worth it in the long term? What is the recommended way to handle this?