How to update a collection via mongoimport in MongoDB?

You can update a collection via mongoimport in MongoDB

--upsert provide you the facility to update the data on basis of _id in MognoDB collection

Take a look on this post here you can learn how to import and export the data from MongoDB
http://web-developers-solution.blogspot.in/2015/01/how-to-import-and-export-data-from-MongoDB-in-json-format.html

After take the backup from MongoDB you can change the data from document but keep in mind do not change the _id

Now like you have imported a collection from mongoDB named user.json
Open the file and make your changes and the save the file

Now you can import the file it will update your document on the basis of _id in documents
mongoimport --collection profiles --db backup --upsert --file user.json

Comments