Courseiva
CRUD Operations →mediumMultiple Choice

C100DBA CRUD Operations Practice Question

A collection called events stores documents with an array field named tags. You need to remove all occurrences of the string "obsolete" from the tags array in every document where the array contains that value, without affecting other elements. Which update operator should you use?

⚠ Common exam trap

Candidates often confuse field removal with array element removal, assuming $unset can delete a value from inside an array.

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

✓

$pull

$pull is the array update operator that removes all elements matching a value or condition. Filtering on documents where tags contains "obsolete" and applying $pull deletes every such occurrence while leaving other tags intact. $unset removes whole fields, $pop removes positional elements, and $set replaces values rather than selectively removing matches.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    $pull

    Why this is correct

    $pull removes all elements from an array that match a specified condition or value. Applied with a filter matching documents whose tags array contains "obsolete", it deletes every occurrence of that string while preserving all other tags. This is precisely the operator designed for removing array elements by value.

  • ✗

    $unset

    Why it's wrong here

    $unset removes an entire field from a document, not individual elements from an array. Using it on tags would delete the whole array, losing all tag values. It cannot target a single string within the array, so it does not meet the requirement of removing only "obsolete" occurrences.

  • ✗

    $pop

    Why it's wrong here

    $pop removes either the first or last element of an array depending on the value 1 or -1. It operates positionally and cannot remove a specific value such as "obsolete" wherever it appears. Since the target string may be in any position, $pop would remove the wrong element and is unsuitable here.

  • ✗

    $set

    Why it's wrong here

    $set assigns a new value to a field. It could overwrite the entire tags array if you supplied the full replacement array, but that requires reading and rewriting the array and risks race conditions. It cannot selectively remove matching elements by value, so it is not the correct operator for this task.

About these practice questions

One of 222 original C100DBA 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 C100DBA 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 C100DBA exam.