Lesson 5: Data Import Tools / Learn
Code Summary: Data Import Tools
Review the following code, which demonstrates how to use the mongoimport tool.
The following command imports the documents from the export.json file into a collection called newCollection in the test database at the URI "mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/". It drops existing data in the new collection before inserting the documents from the export file.
mongoimport \
-v \
--collection newCollection \
--type json \
--mode insert \
--drop \
--file export.json \
"mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/test”
The following options can be used with the mongoimport command. Check out the MongoDB documentation for more information.
--db
--collection
--type
--mode
--upsertFields
--drop
--file