Last active
December 15, 2015 10:49
-
-
Save lslucas/5248041 to your computer and use it in GitHub Desktop.
Mongo Import a single json file to a new collection
This file contains 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
#import a single json file | |
$ mongoimport -h 127.0.0.1 -c subprovider -db techtravel --file subprovider.json | |
#import csv file | |
$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline | |
#export a single collection | |
$ mongoexport --db techtravel --collection subprovider --out /var/www/techtravel/storage/database/2013-04-03/subprovider.json | |
#export a single collection but specific data from that collection | |
mongoexport --db admin -cprovider --out provider-new.json -q '{"hash_id":{"$in" :[ "ryR4eGnq", "R4MnaK8A", "gMG859E8" ]}}' | |
#dump all databases | |
$ mongodump --out /var/www/project/storage/database/date | |
#restore all databases dumped | |
$ mongorestore /var/www/project/storage/database/date | |
#dump all collections from a single db | |
mongodump -d dbname -o storage/database/dateorsomething/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment