Understanding the CQRS principle
In this section, we will learn about CQRS, the different types of CQRS, and why we might want to consider this pattern. CQRS was introduced by Greg Young in 2010. It is based on the command-query separation (CQS) principle that was introduced by Bertrand Meyer, in 1988. In this scenario, we separate the responsibilities of querying or retrieving data from commands, which results in a change in state or mutates our data. The CQRS principle takes the concept of CQS and builds on it, adding more details and capabilities such as having a separate database for reads and writes. This can add complexity but has provided some useful capabilities such as persisting events known as event sourcing. We can play these events back to give us a very detailed audit trail or history of the state of our data: when it changed, who changed it, and why.
Types of CQRS
As mentioned earlier, CQRS was built on the principles of CQS. Additionally, we mentioned CQRS has...