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.
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.