Courseiva
CRUD Operations →mediumMultiple Choice

C100DEV CRUD Operations Practice Question

A logistics application stores shipment records in the 'shipments' collection. Each document includes a 'status' field and a 'deliveredAt' field (a Date). A developer must set 'deliveredAt' to the current date and time for every shipment whose 'status' is 'in_transit' and whose 'carrier' is 'FastShip'. Which operation satisfies this requirement with a single command?

⚠ Common exam trap

The trap here is assuming updateOne updates all matching documents, when it actually modifies only the first match found.

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({ status: 'in_transit', carrier: 'FastShip' }, { $set: { deliveredAt: new Date() } })

The requirement is a filtered, multi-document field update, which maps directly to updateMany with the $set operator. The filter expresses both conditions, and $set preserves the existing document structure while adding or overwriting deliveredAt. The single-document helpers leave other matches untouched, and replacement operations would remove the untouched fields.

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.updateOne({ status: 'in_transit', carrier: 'FastShip' }, { $set: { deliveredAt: new Date() } })

    Why it's wrong here

    updateOne stops after modifying the first matching document, so any other in_transit FastShip shipments would keep a stale or missing deliveredAt value. The requirement demands every qualifying shipment be updated, so the single-document behavior of updateOne leaves the collection partially updated and the task incomplete.

  • ✓

    db.shipments.updateMany({ status: 'in_transit', carrier: 'FastShip' }, { $set: { deliveredAt: new Date() } })

    Why this is correct

    updateMany applies the $set update operator to every document matching the filter { status: 'in_transit', carrier: 'FastShip' }, writing the current date into deliveredAt. The filter combines both conditions with implicit AND, which matches the requirement exactly and updates all qualifying shipments in one round trip.

  • ✗

    db.shipments.replaceMany({ status: 'in_transit', carrier: 'FastShip' }, { deliveredAt: new Date() })

    Why it's wrong here

    There is no replaceMany method in the MongoDB shell; replaceOne is the only replace helper, and it accepts a full replacement document. Even if such a method existed, a replacement document would discard the original fields such as status and carrier, which is not what the scenario asks for.

  • ✗

    db.shipments.findAndModify({ query: { status: 'in_transit', carrier: 'FastShip' }, update: { $set: { deliveredAt: new Date() } }, multi: true })

    Why it's wrong here

    findAndModify does not support a multi option; it is designed to atomically modify one document and return it, so passing multi is ignored or rejected. It could be looped manually, but that is not a single command that updates all matching shipments as the requirement specifies.

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 →

How Courseiva writes practice questions · Editorial policy

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.