Created
March 7, 2016 03:07
-
-
Save githubutilities/44b16e0ade7450d5689d to your computer and use it in GitHub Desktop.
Mongo cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Export to json | |
mongoexport -d <database> -c <collection> -o <out-file> | |
# Export to csv | |
mongoexport --csv -o <out-file> -d <database> -c <collection> -f <field-1>, <field-2> | |
# Import from json | |
mongoimport -d <database> -c <collection> <in-file> | |
# Import from csv | |
mongoimport -d <database> -c <collection> --type csv --file <in-file> | |
# Import from csv with headerline | |
mongoimport -d <database> -c <collection> --type csv --file <in-file> --headerline | |
# Dump database | |
mongodump -d <database> -o <out-directory> | |
# Restore database | |
mongorestore -d <database> <path-to-in-directory> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment