在MongoDB Morphia中是否有一个可以返回多个文档的findAndModify操作?

huangapple go评论60阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月29日 16:35:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76579376.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定