How to perform basic CRUD operations (especially batch) by playing with DDD and CQRS?

Let's say I have a list of IDs in my controller that need to be removed (soft delete). Currently, I treat this operation like any other command:

The controller iterates over the IDs and sends the command to the domain, The aggregate creates an event which is then received by the projector to update the read model. After the reading I came to the correct conclusion, I think, that the operation of removing the model is a more technical topic than a domain one.

And what about it? Is it permissible to skip the Command altogether, create a service in the infrastructure that will be called directly in the controller and update the table for write and read model?

On the other hand, I have a status change operation - kind of similar, but this one is important from the domain point of view, so here I want to stay with Controller-> Command-> Aggregate Root.

  • Neither DDD nor CQRS are necessary or essential for performing basic CRUD operations. DDD isn't a development technique; it is a design technique. It informs where you put your CRUD code. CQRS is an architectural pattern; the motivations for using it are described here. Apr 6, 2022 at 12:42
  • @RobertHarvey But how to perform CRUD operations in an application based on DDD, CQRS? Should treat them equally with all domain operations? Mostly, batch operations. Let's say I have to soft delete 20 entities. Would you then call commands in the controller that will process the aggregate root and create an event that will eventually go to the event handler? Is there an easier way? It is not possible to bypass the domain layer controller, send the request directly to the infrastructure service? Or maybe create a service in the application layer that will handle it?
    – krufkojat
    Apr 6, 2022 at 17:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.