Update Data in MongoDB
Overview
In this guide, you will update a field in a document.
Time required: 10 minutes
What You'll Need
A connection string to your MongoDB deployment.
Sample datasets loaded into your cluster.
Data inserted from Insert Data into MongoDB.
Procedure
Update all documents in the comets
collection.
In the previous guide, you inserted
documents into the comets
collection. Now, you have a
requirement to update those documents. All fields are in metric
units except for the radius
, which is in imperial.
The following example uses an update document to convert
the radius
field from the metric system to the imperial system
in all documents.
Tip
Conversion
1 mile = 1.60934 kilometers
Summary
If you have completed this guide, you have updated data in MongoDB.
In the next guide, you will delete documents from MongoDB.
See Also
See the following resources for more in-depth information about the concepts presented here:
Specify which documents to delete from MongoDB.