Big boi.
Big boi.

Reputation: 13

Which one is domain model in DDD Command or Query?

I'm exploring DDD right now so I see many people apply with CQRS and Event sourcing. My question is which one is Domain model (Command or Query)? Should we focusing on Command model behavior rather than Query because query model can be built up from events as long as Command models are valid.

Upvotes: 0

Views: 718

Answers (2)

VoiceOfUnreason
VoiceOfUnreason

Reputation: 57204

I see many people apply with CQRS and Event sourcing. My question is which one is Domain model (Command or Query)?

Command.

Very loosely, queries are used to ask our system questions about information that is already written down. Commands are used to share new information with our system, so that it can write new things down.

The domain model is where our "decide what to write down" code lives; it's where we expect the "policies" of the business to be enforced.

Upvotes: 2

inf3rno
inf3rno

Reputation: 26129

Keep in mind that I am not an expert of the topic, and the last time I read about this was many years ago. As far as I remember CQRS the query depends on whether you need eventual or immediate consistency for it. If you need immediate consistency, then you cannot use the event queue to build your query database, because it is too slow and you need to maintain a separate database for serving these kind of queries, so this can show up in your domain model. For normal queries the built query databases with e.g. a few secs delay are fine. So your focus is usually command in the domain model, but CQRS does not always work.

Upvotes: 0

Related Questions