CQRS-DDD-ReadModel-Queries in write model?

207 views
Skip to first unread message

Marcos Vitali

unread,
Jan 10, 2021, 6:57:16 PM1/10/21
to DDD/CQRS
Hi, I am using CQRS pattern with Micro ORM for reads and ORM for Writes. 
My question is about Queries in DDD in write model.
is it ok if I need to validate some information with a query in an aggregate complex business logic using the DDD WriteModel?

Thanks, Marcos.

Tomas P.

unread,
Jan 11, 2021, 1:12:27 PM1/11/21
to ddd...@googlegroups.com
Hi Macros,

what exactly do you need to validate during a Query?

Best,
Tomas

--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dddcqrs/72273a3f-df42-4557-996f-4fdce474bf41n%40googlegroups.com.

Erik Landvall

unread,
Jan 11, 2021, 2:32:13 PM1/11/21
to ddd...@googlegroups.com
Hej Marcus

I think validation policies are best defined in the core domain model, used by the anti-corruption layer (the context-mapper). I have more success when the AC is located in the domain, instead of the infrastructure model. 
But really, this is modelling, you should design your component from the perspective of where the defined policies are less likely to create redundancy. 
However, speaking from an orchestration perspective, I consider it a better design when the lower level component is responsible for the business policies.

Regards

Erik Landvall

erik.landvall

erik.landvall



--

Marcos Vitali

unread,
Jan 11, 2021, 8:45:08 PM1/11/21
to ddd...@googlegroups.com
Erik, thanks for your answer. I agree with you, but my problem is not where I put my validation. My Aggregates are very robust, and all methods have guard clauses, business validations, "tell don't ask", additionally my Commands and Queries has basic validations duplicates yes sometime you need to break DRY in the real world and keep it real.
My question is about CQRS and core domain validation that return data. Is it ok to return data from aggregate when you use CQRS, because I feel validations as queries in the core domain and not in the Read Model.

 Thanks in advance.

On Mon, Jan 11, 2021 at 10:06 PM Marcos Vitali <marcos...@gmail.com> wrote:
Tomas P

Any validation that needs to return data, as in the example in the DDD red book shows, page 269 to 279 Authorize User return a value object UserDecriptor. I think the validations that returns data are not Read Model, so i did this in my domain with a query

Thanks in advance.

Marcos Vitali

unread,
Jan 11, 2021, 8:45:08 PM1/11/21
to ddd...@googlegroups.com
Tomas P

Any validation that needs to return data, as in the example in the DDD red book shows, page 269 to 279 Authorize User return a value object UserDecriptor. I think the validations that returns data are not Read Model, so i did this in my domain with a query

Thanks in advance.

On Mon, Jan 11, 2021 at 4:32 PM Erik Landvall <er...@landvall.se> wrote:

Erik Landvall

unread,
Jan 11, 2021, 11:53:33 PM1/11/21
to ddd...@googlegroups.com
I can't really grasp what you are asking, so I think I leave the thread, but good luck.

Erik Landvall

erik.landvall

erik.landvall


Reply all
Reply to author
Forward
0 new messages