InvalidStoredEvent When Retrieving Aggregate if Model Deleted... #311
-
Hey Folks, Not entirely sure whether this is an actual bug or not, but I have an issue retrieving an aggregate when a model that was stored with an event on the aggregate has been deleted and no longer exists. For example, we have a LeagueAggregate and users of the system can join leagues which are linked via a pivot table. When a LeagueJoined event is fired and stored, the user and league models (IDs) are stored in the event properties. If a user is later deleted from the system, trying to retrieve that aggregate will now always return an InvalidStoredEvent exception. So, if future users try to join that league, they'll receive that exception and the system will break. Any ideas on the best way to handle this? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @garethdaine, So your event constructor looks something similar? If yes, then I suggest not storing model as a constructor argument and rather store user_uuid property instead. This way you could always retrieve aggregate and also replay events without depending on database. |
Beta Was this translation helpful? Give feedback.
Hey @garethdaine,
So your event constructor looks something similar?
If yes, then I suggest not storing model as a constructor argument and rather store user_uuid property instead. This way you could always retrieve aggregate and also replay events without depending on database.