What is CQRS? How do I use it?
What are the advantages and disadvantages?
For further actions, you may consider blocking this person and/or reporting abuse
What is CQRS? How do I use it?
What are the advantages and disadvantages?
For further actions, you may consider blocking this person and/or reporting abuse
Michael De Abreu -
chryzcode -
marunkumar1983 -
Aim Hemã de Assis Silva -
Once suspended, oaltena_48 will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, oaltena_48 will be able to comment and publish posts again.
Once unpublished, all posts by oaltena_48 will become hidden and only accessible to themselves.
If oaltena_48 is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to oaltena.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag oaltena_48:
Unflagging oaltena_48 will restore default visibility to their posts.
Top comments (1)
CQRS just means modelling every action, ability or behaviour in your system as either:
(a) a command (write)
(b) a query (read)
Commands change the state of a system.
Queries just tell you the state of the system.
Loosely speaking, in a web app, you would model GET requests as queries and POST requests as commands.
Queries and commands can, at their simplest level, just be a class:
(TypeScript)
Benefits?
It just makes your system much easier to reason about and build. You aren't mixing responsibilities by changing the system AND returning a complex query, etc.
If you need to run your queries in a performant way, then no problem. Your write and read models are separate and not shared.
Your write logic (validation, business rules, etc.) aren't tied up into the same model you use to fetch data (which can become a huge "God" object quickly).
So better performance, easier to maintain, easier to build, etc.