Operations without writing to the DB In DDD

52 Views Asked by At

I'm pretty new to DDD, and I'm doing a project to practice. I am working with CQRS with read and write models with separate DB.

if I have a long process (UI process) where the user requests a large number of queries and can also update and change the requests in the middle. the requests require the write model (or is it the responsibility of the read model) to validate the data and I mean Both for complex logical tests and a simple test that the data is correct in terms of format, etc. In addition, in most cases the write model also needs to calculate the data for the answer, which requires a complex logical process, and only after the calculation send them to the read model, do denormalization and then the client can receive the data, without touching the write and read DB at all (a process that is found in many applications for purchases, etc.).

At the end of the process, the customer can choose to insert the data into the DB.

And the question is how do I do such a thing, until now I'm used to the writing model receiving data, for example from the manager, transferring it to the writing model and when the client requires them they are already ready and you just have to pull them from the reading model, but in this case they don't exist at all at the time of the request.

I thought of a partial solution, but it doesn't seem right, and that the query handler will turn to the write model and do the calculations, and after that turn to the read model and request them (of course, the models themselves are disconnected and communicate via events) I'd love to explain what to do in this situation

0

There are 0 best solutions below