[SERVER-35107] BulkWriteResult has NOT updatedCount property Created: 21/May/18 Updated: 27/Oct/23 Resolved: 18/Jun/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | bo yuan | Assignee: | Nick Brewer |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Steps To Reproduce: |
|
| Participants: |
| Description |
|
with a list of UpdatOne commands executed by bulkWrite(ops), the BulkWriteResult object returned has only property like matchedCount, upsertedCount, etc, with NO updatedCount or modifiedCount. How do I know the number of docs actually updated? |
| Comments |
| Comment by Nick Brewer [ 18/Jun/18 ] | |||||||||||||||||||||||||||||
|
Hi, You can determine the number of updated documents using bulkWriteResult via the nModified property. Since your script is not setting upserting to true or performing any inserts, you're only modifying existing documents - this means that the value of nModified should be sufficient to tell you how many documents have been updated. If you were to introduce upserts or inserts, you would need to make use of additional properties available to bulkWriteResult to see the total amount of documents created and modified. See the documentation for a full list of properties. I do not see anything to indicate a bug in the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. Nick | |||||||||||||||||||||||||||||
| Comment by bo yuan [ 22/May/18 ] | |||||||||||||||||||||||||||||
|
dear Mr Fernandez, My mongo is 3.6.0. Although updatedCount is not found in the bulkwrite result object, the documents in mongo collections have been actually update. my script is like this:
| |||||||||||||||||||||||||||||
| Comment by Ramon Fernandez Marina [ 21/May/18 ] | |||||||||||||||||||||||||||||
|
rambo_yuanbo@outlook.com, do you happen to have a script to reproduce this issue? Also, on which version of MongoDB are you seeing this behavior? Does it reproduce in 3.6.5? Thanks, |