Open hyunbin7303 opened 1 year ago
source from : https://cqrs.nu/tutorial/cs/03-read-models
A read model is a model specialized for reads, that is, queries. It takes events produced by the domain and uses them to build and maintain a model that is suitable for answering the client's queries. It may build and maintain...
- An in-memory model of the data.
- A relational model of the data, stored in an RDBMS.
- Documents, stored in a document database.
- A graph model of the data, stored in a graph database.
- A search index.
- An xml,csv, excel sheet etc.
TodoDetails
or TodoViews
(Read models) are not the only possible outcome of events streaming processing. Such streams can be used for various tasks.
Share events between microservices. From the message bus --> Notification service && analytics service && Read model db.
We need Read model because:
Query the state of a single aggregate is not the only query you want.
You might need to query across many aggregates, or different aggregate types.
You don't need to return the full aggregate state, but only a subset of it.
https://blog.eventuous.dev/read-models-in-event-sourced-systems-489342181233
For the eventsourcing-CQRS pattern, it separates write side(Command) and read side(Query). For the read side, it is desirable to create its own read domain entity for the Todo.
Read model - > any complex logic they encaplsuation is executed asynchronously during event projection. A read model projection function can access existing persistent data, run calcuations of any complexity, and generate as much new or modified data as necessary. The loger a projection takes, the greater the latency of the system,