Insert Data into MongoDB
Overview
In this guide, you will insert data into MongoDB.
Time required: 15 minutes
What You'll Need
A connection string to your MongoDB deployment.
Sample datasets loaded into your cluster.
Procedure
Insert documents into the comets
collection.
Create and insert three new documents for the comets
collection. Each document consists of the following
information about the comet:
The name
The official name
The orbital period in years
The radius in miles
The mass in kilograms
Tip
If you omit the _id
field, the driver
automatically generates a unique ObjectId
value for the
_id
field.
Summary
If you have completed this guide, you have inserted data into MongoDB.
In the next guide, you will learn how to update a field in a document.
See Also
See the following resources for more in-depth information about the concepts presented here:
Specify which documents to update and how to update them in MongoDB.