gruckion / learning

Learning stuff
0 stars 0 forks source link

Command Query Responsibility Segregation for Email Url upload document (CQRS) #16

Closed gruckion closed 5 years ago

gruckion commented 5 years ago

CQRS

gruckion commented 5 years ago

Using a different model to update information from the model you use to read information.

The mainstream approach to dealing with information systems is to use a CRUD data store. In the simple case our interactions are all about storing and retrieving these records.

As our needs become more sophisticated we move away from that model. Instead of record stores we may want to collapse multiple records into one or create virtual records by combining information for different places.

CQRS suggests to change the above and split the conceptual model into seperate models for update and display. These are refereed to as the Command and Query respectively CommandQuerySeparation

In this picture. We can see the query model reads from the database and the query service updates the UI from this model. Then the user makes some changes to the UI which the application routes this change information to the command model. The command models validation/consequential logic fires. The command model then updates the database.

TODO: Reporting Database

gruckion commented 5 years ago

The feedback from James A is that command is the what and command handler is the how. So if we wish to redirect a generated link and use link2 if boolean is true. Then we would do this logic in the command. Then we would parse the commuted link to the handler so it can do what it usually does.