C100DEV CRUD Operations Practice Question
A developer wants to remove all documents from the 'logs' collection where the 'level' field equals 'debug'. The collection has an index on level. Which operation should be used, and what does it return?
⚠ Common exam trap
The trap here is choosing deleteOne or drop when the requirement is to remove every document matching a predicate while keeping the collection intact.
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
✓
deleteMany({ level: 'debug' }) returns a result whose deletedCount is the number of documents removed.
deleteMany with a filter removes all matching documents and reports how many were deleted via deletedCount. deleteOne only removes the first match, drop destroys the whole collection, and remove is deprecated. When a selective deletion is needed and the filter is indexed, deleteMany preserves unrelated documents and existing indexes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
deleteMany({ level: 'debug' }) returns a result whose deletedCount is the number of documents removed.
Why this is correct
deleteMany removes every document matching the filter and returns a DeleteResult with deletedCount set to the number removed. Because the collection has an index on level, the filter can be served efficiently. This matches the requirement to remove all debug-level logs while preserving other documents and the collection's indexes.
- ✗
drop() removes the collection and its index, which is the recommended way to clear matching documents.
Why it's wrong here
drop() removes the entire collection, including all documents and indexes, not just documents matching a predicate. It would also discard the index on level and other log entries that do not match. It is far too destructive for selectively deleting debug-level documents.
- ✗
deleteOne({ level: 'debug' }) returns the number of documents removed.
Why it's wrong here
deleteOne removes only the first matching document, not all matching documents, so it would leave other debug logs behind. Its result reports deletedCount as 1 or 0, which does not satisfy the requirement to remove every matching document. For removing all matches, deleteMany is the correct method.
- ✗
remove({ level: 'debug' }) is the modern method and returns a cursor of deleted documents.
Why it's wrong here
The remove() method is deprecated in the MongoDB shell and was never part of the standard driver CRUD API. It does not return a cursor of deleted documents; no delete operation returns deleted document contents. The current API uses deleteOne and deleteMany, which return a DeleteResult with a count.
About these practice questions
Courseiva writes every C100DEV question from scratch — 259 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.