| name | cqrs |
| description | CQRS command query responsibility segregation. Use for complex domains. |
CQRS (Command Query Responsibility Segregation)
CQRS is a pattern that separates read and update operations for a data store. Instead of using a single model for both, you have a Command Model (Write) and a Query Model (Read).
When to Use
- High Disparity: Read load is 1000x higher than Write load (or vice versa).
- Complex UI: The UI needs data shaped differently than the way it's stored (e.g., Dashboard aggregation).
- Event Sourcing: CQRS is almost mandatory for Event Sourcing.
Quick Start (Conceptual)
class CreateOrderCommand { ... }
class OrderAggregate {
create(cmd: CreateOrderCommand) {
}
}
class GetOrderSummaryQuery { ... }
class OrderSummaryProjector {
on(event) {
}
}