Reputation: 23
So I'm struggling to model a fairly simple and very common relationship. I have a complex app with a lot of entities, I want to model a use case, and for this UC I have 3 entities, organization, user and invite. This are the business rules/constraints:
So under this context, User is an aggregate root, I think organization is another aggregate root (there are other entities that are related to the org), now I do not really understand what invite is, I'm leaning towards aggregate root as well, but the problem is that if that is the case, when accepting an invite I need to modify the invite and the user in the same transaction, which I believe is something we want to avoid. Any ideas?
Upvotes: 1
Views: 1931
Reputation: 57317
Can I modify two aggregates in a single transaction?
Yes, you can... if you are willing to accept the trade offs involved (restrictions on your choice of durable storage, increased need for conflict resolution, and so on).
But: the pressure to combine aggregates into a single transaction is often a symptom of either (a) failing to recognize that the model should be supporting intermediate/non-equilibrium states or (b) accidental complexity in the form of incorrectly designed domain entities.
Any ideas?
Consider whether you can satisfy your requirements by modeling the invitation process, rather than trying to model the Nouns. Consider whether you model is best served by links to mutable data references or instead by making an immutable copy of the data you need.
Upvotes: 1