Ok I found some time to revisit the project and I still do not get a
few things.
First of all my entities all have an ID and for now I put User and
City in separate streams and appended their ID so I can make
projections by category with the ID. But this leaves still a problem
that I do not seam to be able to solve. My aggregate is the User and
the Users has a Town as a field. Lets say when I create a City, I do
not need a User, but there should be a "UserMovedToCity" Event that
consists of a user Id and a City ID. I would put this is the user
stream so when I load the User, I will have a json object like
UserId: 14
UserName: "Peter"
City:
{
CityId: 123
CityName: null
}
But this is not a valid state of my aggregate, as CityName should
always be set. But a "CityCreated" event only would have a CityId and
a CityName. So what I would have to do is load the User in its non
valid state and apply the corresponding City onto him. But those are
two requests and just does not seem right at all.
I was thinking of making a projection with linkTo from the CityStream
to the user Stream, but this is not very good aswell. I also was
thinking of putting the city events in the user stream, as they are
one aggregate, but then I would have the problem to decide where to
put a "CityCreated" event or a "CityNameChanged" event would have to
be applied to all user aggregates that are living in this city. Those
are all terrible ideas but I can not seam to figure out how I would
implement such a parent child relationship.
Maybe the example is really bad, as in real live I would model them as
two separate aggregates and would only have a CityId as a Property in
the User Aggregate. But I am pretty sure that there will be a day
where I would really have to implement a Parent Child relationship
within an aggregate and then I would have to have an Idea how to
handle this.
Thanks for the insides so far, It was very helpfull!
Greetings
Simon