I am trying to model a very simple domain which has the conceptual (one)PARENT --> (many)CHILD. The problem being that the number of children in the relationship may be in the millions.
I'm trying to construct an aggregate root that will allow me to "put" (update or insert if doesn't exist) a single child at a time. However, the values being updated must be validated beforehand by the parent.
What patterns can I use to approach this? Currently I have considered the following:
PARENT as aggregate root
CHILD as aggregate root
BOTH as aggregate roots
You haven't understood what an aggregate root (AR) is. It isn't a parent container for children. It's s concept where has should be handled as is defined by . One to many has nothing to do with identifying an AR.
A "child" is a concept that makes sense to exist in AR context i.e it's part of the aggregate represented by the AR. Your example seems to define a repository, a container of items. And it does look a bit like CRUD functionality.
Are you sure you are in an aggregate and not in a context where a simple service is enough?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With