🏗️Command Query Responsibility Segregation (CQRS)
Also known as CQRS, Command Query Separation
Splitting the code that changes data from the code that reads it.
Think of it like
Think of it like a library with two desks. One takes books back, and one helps you find them.
Example
Emma's shop saves orders in a strict database that checks each rule. A second, simpler copy feeds the order history page. That page loads in a blink.
Why it matters
Reads and writes often have very different needs. Splitting them lets each be shaped and scaled on its own.
Definition
Common mistake
Key takeaways
- 1Commands change. Queries only read.
- 2Separate models. Each fit for its job.
- 3Only when needed. It adds parts.