简体   繁体   English

MongoDB批量API:找出匹配的批量更新

[英]MongoDB bulk API: Finding out whch bulk updates matched

I'm doing multiple updates in a single bulk. 我要在一个批量中进行多个更新。 Note: they are updates, not upserts. 注意:它们是更新,不是更新。 The problem doesn't allow it. 问题不允许。 Is there a way to find out which commands form the bulk matched (or didn't)? 有没有办法找出哪些命令构成了批量匹配(或没有)?

From what I saw in the manual, you can only find the number of matches from BulkWriteResult, not which one matched, but I thought I'd ask anyway. 根据我在手册中看到的内容,您只能从BulkWriteResult中找到匹配项的数量,而没有找到匹配的项,但是我还是想问一下。 Thanks for the help. 谢谢您的帮助。

The BulkWriteResult doesn't contain this information and, as of MongoDB 2.6.3, there's no way to obtain it from the execution of the bulk operation. BulkWriteResult不包含此信息,并且从MongoDB 2.6.3开始,无法从批量操作的执行中获取信息。 Of course, since you specify the criteria to determine which documents are updated, you can find out which documents are updated from the results of a find query with the same criteria. 当然,由于您指定了确定要更新哪些文档的条件,因此可以从具有相同条件的查找查询的结果中找出要更新的文档。 as long as the documents don't change in between. 只要文档之间没有变化。 During a multistage bulk operation, you might change what documents match the update. 在多阶段批量操作中,您可能会更改与更新匹配的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM