Closed danjampro closed 3 years ago
Maybe a lock is not the best solution as this would require a server / client in addition to the existing mongodb
. There maybe alternatives, e.g. using mongodb
unique indices:
https://docs.mongodb.com/manual/core/index-unique/#std-label-index-type-unique
These methods are not currently thread-safe e.g. because two documents that are inserted simultaneously may both satisfy the uniqueness criteria in
collection.find()
before actually getting inserted into the mongodb collection.