Courseiva

C100DEV · topic practice

CRUD Operations practice questions

The CRUD Operations domain covers creating, reading, updating, and deleting documents in MongoDB using the shell and drivers. Questions present realistic scenarios—dynamic arrays, upserts, conditional field updates—and ask you to choose the correct query operator, update operator, or command option that produces the required result.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Editorial oversight:Johnson Ajibi· MSc IT Security, IEEE Senior Member
20 questionsDomain: CRUD Operations

What the exam tests

What to know about CRUD Operations

Be able to read a scenario and pick the exact MongoDB operator or option: $all for multi-element array matches, upsert:true for insert-on-missing, and $set combined with $exists:false for conditional field addition. The most important thing is matching the operator to the stated matching or update behavior.

Using $all to match array documents containing multiple specified elements regardless of order

Applying updateOne with upsert:true to insert a document from filter and update fields

Using $set with a filter and $exists:false to add fields conditionally

Selecting find, insertOne, updateMany, and deleteMany for collection-level document operations

Watch out for

Common CRUD Operations exam traps

  • ▸Confusing $all with $in: $in matches any listed value, while $all requires every listed value to be present in the array.
  • ▸Forgetting that upsert inserts only when no document matches the filter, and that filter equality fields are included in the new document.
  • ▸Using $set without an $exists:false condition, which overwrites existing field values instead of adding the field only when absent.

Practice set

CRUD Operations questions

20 questions · select your answer, then reveal the explanation

Question 1mediummultiple choice
Read the full CRUD Operations explanation →

An application needs to update a document in the 'orders' collection. If the document matching the query does not exist, a new document must be inserted using fields from both the query and the update document. Which parameter accomplishes this behavior?

A developer is writing a bulk operation against the 'inventory' collection using db.inventory.bulkWrite(). The batch must (1) insert a new item only if no document already exists with the same 'sku', and (2) increment the 'qty' field of an existing item by 5 in the same round trip. Which two operations should be included in the bulkWrite array to meet these requirements? (Choose two.)

A booking system stores reservations in the 'reservations' collection. Each document has a 'guests' array of embedded subdocuments, each with 'name' and 'checkedIn' fields. An operator needs to mark only the subdocument whose 'name' is 'M. Chen' as checked in, leaving all other array elements unchanged. Which update accomplishes this?

Question 4mediummultiple choice
Read the full CRUD Operations explanation →

A monitoring service writes metric documents with a 'sensorId' field to the 'metrics' collection. The application occasionally retries writes and must avoid creating duplicate documents when a document with the same 'sensorId' already exists. The update should set 'lastSeen' to the current date and increment a 'readings' counter when the sensor already exists. Which operation meets both requirements?

A developer needs to retrieve documents from the 'sensors' collection where the 'readings' array contains at least one element greater than 100, but the query must return only the first matching element from each array. Which projection correctly limits the returned array to the first matching element?

A logistics application stores shipment documents in the 'shipments' collection, where each document has an 'events' array of subdocuments containing 'status' and 'timestamp' fields. A developer must append a new event to the 'events' array only if no event with the same 'status' and 'timestamp' already exists, to avoid duplicate entries during retries. Which update operation achieves this?

A developer is working with a 'logs' collection where each document has a field 'timestamp' of type Date. They need to find all documents where the timestamp is in the year 2023. Which two queries will achieve this? (Choose two.)

A media application stores user profiles in the 'profiles' collection. A developer must remove a deprecated field named 'legacyScore' from all documents in the collection without affecting any other fields or documents. Which two operations accomplish this? (Choose two.)

A social media application stores user profiles in the 'profiles' collection. Each document has a field 'username' that should be unique. You need to insert a new profile document, but only if the username does not already exist. If it exists, the insert should fail and return an error. Which method should you use?

Question 10mediummultiple choice
Read the full CRUD Operations explanation →

An application needs to update a user document in the 'users' collection. If the document does not exist, a new document must be inserted using fields from both the filter and the update document. Which parameter accomplishes this behavior in MongoDB?

Question 11mediummultiple choice
Read the full CRUD Operations explanation →

You are designing an e-commerce catalog where products can have a dynamic array of tags. You need to query for documents where the 'tags' array contains both 'electronics' and 'sale' simultaneously, regardless of their order or other elements. Which query operator should you use?

Question 12mediummultiple choice
Read the full CRUD Operations explanation →

A support ticketing system stores documents in the 'tickets' collection. An operator wants to add a new field 'priority' set to 'high' only for tickets whose 'status' is 'open' and that do not already have a 'priority' field. The update must not create any new documents and must not modify tickets that already have a 'priority' field. Which update operation should be used?

Question 13mediummultiple choice
Read the full CRUD Operations explanation →

A logistics application stores shipment documents in the 'shipments' collection. Each document has a 'packages' array of embedded subdocuments, each with a 'trackingCode' field. A developer needs to remove only the embedded subdocument whose 'trackingCode' equals 'TRK-9981' from the document with '_id' 42, leaving all other packages untouched. Which update operation should be used?

Question 14easymultiple choice
Read the full CRUD Operations explanation →

A reporting service reads from the 'sensors' collection, which holds millions of documents each containing an 'active' boolean field. The service queries only for documents where 'active' is true and reads a handful of fields. A developer wants the query to avoid scanning documents that are inactive. Which index should be created to support this access pattern most directly?

Question 15mediummultiple choice
Read the full CRUD Operations explanation →

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?

Question 16hardmultiple choice
Read the full CRUD Operations explanation →

An analytics job updates counters in the 'metrics' collection with db.metrics.updateOne({ metric: "visits" }, { $inc: { count: 1 } }). The job runs with write concern w:1 against a three-node replica set, and a failover occurs immediately after the primary acknowledges a write. The developer reports that a counter increment appears to be lost. Which statement best explains this outcome?

Question 17easymultiple choice
Read the full CRUD Operations explanation →

A developer is exploring a 'reviews' collection and wants to retrieve only the 'author' and 'rating' fields from every review document, without the _id field, to reduce the payload sent to the application. Which query accomplishes this?

Question 18mediummultiple choice
Read the full CRUD Operations explanation →

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?

Question 19mediummultiple choice
Study the full Python automation breakdown →

A developer is writing a Python application using the official MongoDB driver to insert a single document into the 'inventory' collection. They call `inventory.insert_one({'sku': 'A100', 'qty': 5})`. Which statement accurately describes what happens?

Question 20mediummultiple choice
Read the full CRUD Operations explanation →

A reporting service reads from the 'sensor_readings' collection, which contains millions of documents. The service runs a query that filters on 'deviceId' and returns results sorted by 'recordedAt' descending. The query performs a collection scan and an in-memory sort, causing high memory usage. Which index should you create to allow the query to use an index for both filtering and sorting?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused CRUD Operations sessions

Start a CRUD Operations only practice session

Every question in these sessions is drawn from the CRUD Operations domain — nothing else.

Related practice questions

Related C100DEV topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the C100DEV exam test about CRUD Operations?
Be able to read a scenario and pick the exact MongoDB operator or option: $all for multi-element array matches, upsert:true for insert-on-missing, and $set combined with $exists:false for conditional field addition. The most important thing is matching the operator to the stated matching or update behavior.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just CRUD Operations questions in a focused session?
Yes — the session launcher on this page draws every question from the CRUD Operations domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other C100DEV topics?
Use the topic links above to move to related areas, or go back to the C100DEV question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the C100DEV exam covers. They are not copied from any real exam or dump site.