Courseiva

C100DEV · domain

CRUD Operations

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.

26 questions5 easy13 medium8 hard

Focused practice

Practice CRUD Operations questions

Scored sessions drawing only from this domain — pick a length below.

What this domain covers

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.

Question index

All CRUD Operations questions (26)

Click any question to see the full explanation, or start a practice session above.

1

A MongoDB application stores inventory documents in the 'inventory' collection with fields 'sku', 'on_hand', and 'reserved'. During a flash sale, many concurrent sessions must decrement 'on_hand' by 1 only when on_hand is greater than 0, and each successful decrement must return the resulting document to the client. Which approach guarantees this behavior?

Hard
2

A developer is troubleshooting a Python application that uses the MongoDB driver to query the 'products' collection with find({'category': 'tools'}). Which two statements about the returned cursor are correct? (Choose two.)

Medium
3

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?

Medium
4

An inventory collection stores documents with a numeric 'quantity' field. A warehouse system must decrement quantity by 5 on a specific item, and if the field is missing it should be created starting from the decremented value. Which update operator and command achieve this?

Medium
5

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?

Medium
6

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?

Medium
7

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?

Hard
8

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?

Medium
9

A sensor platform writes readings to the 'readings' collection. A developer needs to insert three documents in a single operation and have the server process them in the given order, stopping at the first error rather than continuing. Which insert command should be used?

Medium
10

A developer needs to insert a single document into the 'inventory' collection and wants the operation to return the generated _id value in the result. Which method should be used?

Easy
11

A developer is querying the 'events' collection to retrieve documents and needs to control which fields are returned to reduce network payload. Which two statements about projection in MongoDB find() operations are correct? (Choose two.)

Medium
12

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?

Medium
13

A banking application must atomically transfer funds between two account documents in the 'accounts' collection. The transfer decreases the balance of the source account and increases the balance of the destination account, and both changes must succeed or neither should be applied. The deployment is a replica set. Which approach guarantees this atomicity?

Hard
14

A logistics application stores shipment records in the 'shipments' collection. A developer must delete all shipment documents whose 'status' field equals 'cancelled'. Which command correctly performs this operation?

Easy
15

A document in the 'profiles' collection has an embedded array 'contacts' of subdocuments, each with 'type' and 'value' fields. A developer must change the 'value' of the subdocument whose 'type' is 'email' without altering any other array element. Which update is correct?

Hard
16

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?

Medium
17

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?

Medium
18

A logistics application stores shipment events in the 'shipments' collection. Each document contains a field 'events' that is an array of subdocuments with fields 'status' and 'timestamp'. You need to remove the subdocument where 'status' equals 'cancelled' from all documents in the collection, without affecting other array elements. Which update operation should you use?

Medium
19

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?

Easy
20

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?

Medium
21

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?

Easy
22

A developer queries the 'events' collection with db.events.find({ tags: { $in: ["sports", "music"] } }) and observes a COLLSCAN in explain output even though an index exists on the 'tags' array field. The collection holds a few hundred documents. Which explanation best accounts for the planner choosing a collection scan?

Hard
23

A blog platform stores posts in the 'posts' collection. Each document has an array field 'comments' containing subdocuments with fields 'author' and 'text'. You need to add a new comment to the 'comments' array of a specific post identified by its '_id'. The new comment should be appended to the end of the array. Which update operation should you use?

Hard
24

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?

Easy
25

A financial application stores transactions in the 'transactions' collection. Each document has fields: 'accountId', 'amount', 'timestamp', and 'status'. You need to find all transactions for account 'A123' that have an amount greater than 1000 and a status of either 'pending' or 'review'. Which two query documents correctly retrieve these transactions? (Choose two.)

Hard
26

A developer must update a document in the 'accounts' collection by incrementing the 'balance' field by 25 and simultaneously setting the 'lastUpdated' field to the current date. The update must apply only if the account is active. Which update statement satisfies all conditions?

Hard

Frequently asked questions

What does the CRUD Operations domain cover on the C100DEV exam?
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 many questions are in this domain?
This page lists all 26 CRUD Operations questions in the C100DEV question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only CRUD Operations questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
mongodb-associate-developer MONGODB-ASSOCIATE-DEVELOPER mongodb crud operations Practice Questions