I have an aggregate, let's call it Party. For a party, I can have many People which is an aggregate as well as they can exist on their own without the Party. But specifically for the Party , I want to keep track of how much Food was eaten by each person.
How can I model this? The Food cannot exist without the People at the Party so I don't consider this a separate aggregate. Food has items inside it.
I have modelled Party as follows:
{ partyId: number people: [ { peopleId: number food: { sausages: 2 burgers: 5 } } ] } Is this the correct way to model the data?
If I want to get the details for one person at a Party, how would I model the method? Is it a case of having a repository method to get a party by its id and then filtering the People array by the id of the person I want?
I have modelled the data but it doesn't feel quite right to me.
Edit:
Thanks to one of the answers, I have changed the Party aggregate to be:
{ id: number participants: [ { personId: number food: { kind: string quantity: number } } ] } The People aggregate has been renamed Person:
{ id: number name: string } This better communicates the relationship and I think is easier to understand.
