Last active
September 26, 2015 18:38
-
-
Save dtsdwarak/d50b256f6b14bd06a4bf to your computer and use it in GitHub Desktop.
Mongo to Couch
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
#Mongo to Couch | |
# Step1 : Export your mongo database | |
mongoexport -d <database_name> -c <collection_name> -o <output_file>.json --jsonArray | |
# Strip off the _id that mongo introduces to change it to id | |
sed ‘s/_id/id/g’ <output_file>.json > <changed_file>.json | |
# Include headers and footers decoration stuff the Couch requires | |
echo "{\"docs\":`cat <changed_file>.json`}" > <changed_file>.json | |
#Upload to Couch | |
curl -d @<changed_file>.json -X POST <host_ip_address>:5984/<db_name> -H “Content-Type: application/json” |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment