Exam C100DBA Topic 3 Question 30 Discussion

Actual exam question for MongoDB's C100DBA exam
Question #: 30
Topic #: 3
A MongoDB administrator is managing a database for a hospital system.
The patients collection contains:
- Carlos Martinez, diagnosis Hypertension, room 203
- Maria Lopez, diagnosis Hypertension, room 207
- Juan Perez, diagnosis Arrhythmia, room 207
The administrator runs:
db.patients.updateMany(
{ diagnosis: " Hypertension " },
{ $set: { room: 207 } }
)
What output should the administrator expect?

Suggested Answer: D Vote an answer

updateMany() distinguishes between documents that match the filter and documents whose stored data actually changes. The filter { diagnosis: " Hypertension " } matches Carlos Martinez and Maria Lopez, so matchedCount is 2. Carlos currently has room: 203, and $set: { room: 207 } changes his document, contributing one to modifiedCount. Maria already has room: 207. She still satisfies the filter and therefore counts as a match, but setting a field to the value it already contains does not produce a material modification, so she does not increment modifiedCount. Juan Perez has diagnosis Arrhythmia, so he is neither matched nor modified. The resulting acknowledged operation therefore reports matchedCount: 2 and modifiedCount: 1, corresponding to option D. This distinction is essential when validating whether an update actually changed stored values rather than merely identifying matching records. This distinction is operationally important: a large difference between matched and modified counts can indicate that many matching documents already contained the requested state, not that the update failed. DBAs should use both counters when validating bulk- update behavior.
Study Guide reference/topic:MongoDB Architecture and Core Operations - updateMany(), $set, matchedCount, and modifiedCount.

by Hugo at Oct 15, 2026, 05:41 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10