英文:
Is there a findAndModify that returns many documents in MongoDb Morphia
问题
我正在使用MongoDb Morphia for Java
,我想要使用一条命令悲观锁定多个文档。我熟悉findAndModify
方法,它可以找到并更新一个文档。是否有一种方法可以用于多个文档?
英文:
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?
答案1
得分: 1
findAndModify()
只适用于由服务器行为定义的单个文档。如果您希望在一个全有或全无的块中更新多个文档,您可以考虑使用 transaction。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论