Skip to content

Instantly share code, notes, and snippets.

@vikas-git
Created July 18, 2019 07:51
Show Gist options
  • Save vikas-git/c06e018ee9c391480e62e025d5a2bd66 to your computer and use it in GitHub Desktop.
Save vikas-git/c06e018ee9c391480e62e025d5a2bd66 to your computer and use it in GitHub Desktop.
Some common and important commands for MONGODB
For Dump and Restore :
mongodump --db=<old_db_name> --collection=<collection_name> --out=data/
mongorestore --db=<new_db_name> --collection=<collection_name> data/<db_name>/<collection_name>.bson
Loop on mongodb query:
db.users.find().forEach( function(myDoc) { print( "user: " + myDoc.name ); } );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment