C100DEV CRUD Operations Practice Question
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?
⚠ Common exam trap
The trap here is assuming insert_one performs an upsert or requires an explicit _id, when it is a plain insert with a driver-generated identifier.
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
✓
The driver sends an insert command; MongoDB adds the document with a generated _id and returns an InsertOneResult containing the inserted_id.
The insert_one method inserts a single document and returns an InsertOneResult whose inserted_id exposes the generated identifier. It does not upsert, does not defer writes to connection close, and does not require the application to provide _id. Understanding this return object matters because applications commonly need the generated _id to link related documents or respond to clients.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The driver performs an upsert automatically, so if a document with the same sku exists it replaces it.
Why it's wrong here
insert_one() never performs an upsert. It always attempts a plain insert, and if a unique index on sku already contains 'A100', the operation fails with a duplicate key error rather than replacing the existing document. Upsert semantics belong to update operations using the upsert option, not to insert_one.
- ✗
The server rejects the insert because the document lacks an explicit _id field, requiring the application to supply one.
Why it's wrong here
MongoDB does not require the application to supply an _id. If the document passed to insert_one() omits _id, the driver generates an ObjectId client-side and includes it in the insert command. The server only rejects a write when an _id value violates uniqueness constraints, not when it is absent.
- ✗
The document is written only to the driver's local buffer and flushed to the server when the client closes the connection.
Why it's wrong here
The MongoDB driver does not buffer individual inserts for later flushing on connection close. insert_one() writes to the server within the operation and, under default write concern, waits for acknowledgment. Relying on connection close to persist data would make durability unpredictable and is not how the driver works.
- ✓
The driver sends an insert command; MongoDB adds the document with a generated _id and returns an InsertOneResult containing the inserted_id.
Why this is correct
insert_one() sends an insert command to the server, which generates an _id if omitted and stores the document. The driver returns an InsertOneResult object whose inserted_id attribute holds the generated ObjectId, letting the application reference the new document later. This is the documented behavior of the PyMongo insert_one method for a single-document write acknowledged by the server.
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.