Chapter 7: Implementing Queries
In the section Command Query Responsibility Segregation (CQRS) from Chapter 3, Understanding the Domain, we described how DDD and CQRS complement each other and how the query side (read models) can be used to create one or more representations of the underlying data. In this chapter, we will dive deeper into how we can construct read-optimized representations of the data by listening to domain events. We will also look at persistence options for these read models.
When working with query models, we construct models by listening to events as they happen. We will examine how to deal with the following situations:
- New requirements evolving over a period of time, requiring us to build new query models.
- We discover a bug in our query model that requires us to recreate the model from scratch.
To do that, the agenda of the chapter includes the following topics:
-
...