modernice / goes

goes is an event-sourcing framework for Go.
https://goes.modernice.dev
Apache License 2.0
134 stars 12 forks source link

Remove unnecessary consistency validation from MongoDB event store #180

Open bounoable opened 11 months ago

bounoable commented 11 months ago

178 made me realize that the MongoDB event store already creates a unique index for "aggregateName" + "aggregateId" + "aggregateVersion". So I'm not sure why I implemented the consistency check using a separate state collection. The index should already ensure optimistic concurrency for aggregates, so I think the additional check can be removed.

Note: The event store must still return a VersionError if the insertion fails because of the index violation.