javamongodbmorphia

Is there a findAndModify that returns many documents in MongoDb Morphia


I am using MongoDb Morphia for Java and I want to pessimistically lock many documents with one command. I am familiar with the findAndModify method, which will find and update one document. Is there a method that will do the same for multiple documents?


Solution

  • findAndModify() only works with a single document as defined by the server's behavior. If you're wanting to update multiple documents in one all-or-nothing block, you might consider using a transaction.