I’ve been playing with event sourcing and EventStore in my free time and I’ve encountered this issue so I thought it might be best to ask here.
To my knowledge Aggregates are generally the source of truth for the write side of your system, but they’re also difficult to query against. Let’s say I have a business rule that requires a user to have a unique Username; unless that’s a part of the stream’s ID, then it would be problematic to try and locate any aggregates with that Username (and thus validate against the Username being unique).
The other solution would be using a readmodel to accomplish this but I’m unsure if this is best practice to check against readmodels on the write side, especially with them being eventually consistent.
I’m sure this is something that people have encountered so I’d be interested to hear what strategies people use for this.