Docs Home → Develop Applications → MongoDB Manual
Insert Documents![](/docs/v5.3/assets/link.svg)
➤ Use the Select your language drop-down menu in the upper-right to set the language of the examples on this page.
This page provides examples of insert operations in MongoDB.
Note
Creating a Collection
If the collection does not currently exist, insert operations will create the collection.
Insert a Single Document![](/docs/v5.3/assets/link.svg)
To retrieve the document that you just inserted, query the collection:
Insert Multiple Documents![](/docs/v5.3/assets/link.svg)
➤ Use the Select your language drop-down menu in the upper-right to set the language of the examples on this page.
Insert Behavior![](/docs/v5.3/assets/link.svg)
Collection Creation![](/docs/v5.3/assets/link.svg)
If the collection does not currently exist, insert operations will create the collection.
_id
Field![](/docs/v5.3/assets/link.svg)
In MongoDB, each document stored in a collection requires a unique
_id field that acts as a primary key. If an inserted
document omits the _id
field, the MongoDB driver automatically
generates an ObjectId for the _id
field.
This also applies to documents inserted through update operations with upsert: true.
Atomicity![](/docs/v5.3/assets/link.svg)
All write operations in MongoDB are atomic on the level of a single document. For more information on MongoDB and atomicity, see Atomicity and Transactions
Write Acknowledgement![](/docs/v5.3/assets/link.svg)
With write concerns, you can specify the level of acknowledgement requested from MongoDB for write operations. For details, see Write Concern.