C100DEV CRUD Operations Practice Question
A logistics MongoDB deployment has a 'shipments' collection. A nightly job must remove the 'tracking_history' array element whose 'status' is 'cancelled' from every document where 'carrier' is 'DHL', without deleting the documents themselves. Which update operation should the developer run?
⚠ Common exam trap
Many exam-takers confuse $unset, which drops a field, with $pull, which removes array elements matching a condition.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
db.shipments.updateMany({ carrier: 'DHL' }, { $pull: { tracking_history: { status: 'cancelled' } } })
The $pull operator is designed to remove array elements that match a specified condition, so using it with updateMany and a carrier filter deletes only the cancelled tracking_history entries from every DHL shipment. Operations like deleteMany or $pop either remove whole documents or the wrong array elements, and $unset cannot filter by element values.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
db.shipments.updateMany({ carrier: 'DHL' }, { $pop: { tracking_history: { status: 'cancelled' } } })
Why it's wrong here
$pop removes either the first or last element of an array based on a value of -1 or 1, and it does not evaluate a field condition such as status: 'cancelled'. Passing an object to $pop is invalid. It cannot target specific array elements by their contents, so it fails the requirement.
- ✗
db.shipments.deleteMany({ carrier: 'DHL', 'tracking_history.status': 'cancelled' })
Why it's wrong here
deleteMany removes whole documents that match the filter, which would erase any DHL shipment containing at least one cancelled entry. The task explicitly requires keeping documents and removing only the array element. This operation destroys shipment records and is therefore incorrect.
- ✓
db.shipments.updateMany({ carrier: 'DHL' }, { $pull: { tracking_history: { status: 'cancelled' } } })
Why this is correct
The $pull operator removes all array elements matching a condition, so specifying { status: 'cancelled' } strips only those entries from tracking_history. Combining it with updateMany and a carrier filter applies the change to every matching document. This satisfies the requirement to delete array elements without removing documents.
- ✗
db.shipments.updateMany({ carrier: 'DHL' }, { $unset: { 'tracking_history.status': 'cancelled' } })
Why it's wrong here
$unset removes a field entirely rather than an array element, and it does not accept a value condition like 'cancelled'. Using it on tracking_history.status would either delete the status field from every element or fail, leaving cancelled entries present. It cannot selectively remove only the cancelled array elements.
About these practice questions
One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.