Posts

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

How to import and export the data from MongoDB in json format?

You can use these query to import and export the data from MongoDB in JSON format. First of all you need to install MongoDB in your system. Then open cmd with administrator Now go to mongodb bin directory like C:\wamp\bin\mongodb\mongodb-win32-x86_64-2008plus-2.4.12\bin Then run this command Query to Export mongoexport --db databasename --collection collectionname --out filename.json Now you need to import the data from your file which you have backup recently Query to Import mongoimport --collection collectionname --db databasename --file filename.json By use these query you can import and export the data from mongoDB in json format Now if you have to use these query then use same process to import and export Then open cmd with administrator  and then run these command with your mongoDB details Query to import mongoimport --host hostname --port 27017 --username yourusername --password yourpassword --collection collname --db dbname --file filename.json Upda