If yes then it means basically what people call read model which not reading only. Your architecture might be simple enough that the read side just queries the db (that is already up-to-date from the command side!). If you're not using events then it's different. When you receive an event, update a database, or an in-memory model.These could be implemented in a simple console app for example, or inside an API. For example, if using EventStore the client has built in support for the concept of subscribers. The actual implementation of these would depend on your architecture. You would listen to events, then update your read models. If you're using events, it will be the subscribers to the events. The main question is what the part is responsible for updating projections/query part? You have still separated your reads from your writes, you just haven't used events. This query doesn't go through the domain model. that reads from the same storage as your write side.įor example, an API or web page request comes in, you execute a query against your database, then return the results to the user. In this scenario, the concept of a read model might just be a database query. However, you can also have CQRS without events. You would then query these read models by loading them from the database or the in-memory model. You could subscribe to events, then update read models in some database (could be tables in a SQL database, documents in a document database), or in an in-memory object model. It depends on your storage and how you are "creating" your read models. If yes then it means basically that something what people call read model is not reading only from the storage. Then read model, which has to be subscribed on such event, handle it and update own projection is this correct? The command side is for protecting the invariants of your domain, You could, for example, just update some state in a sql database. However, I don't believe CQRS mandates using events. This is a good way to do it (especially combined with event sourcing where your database is your events). This is also where you would raise domain events. This is the point where your business rules and behaviour live. You load your aggregate and apply some behaviour. The write/command side is the domain model with the responsibility of making sure the system is in the correct state - if using DDD then through aggregates.
0 Comments
Leave a Reply. |