It's not possible to lock a mongodb document. What if I need to?
问题 I know that I can't lock a single mongodb document, in fact there is no way to lock a collection either. However, I've got this scenario, where I think I need some way to prevent more than one thread (or process, it's not important) from modifying a document. Here's my scenario. I have a collection that contains object of type A. I have some code that retrieve a document of type A, add an element in an array that is a property of the document ( a.arr.add(new Thing() ) and then save back the