Skip to content

Instantly share code, notes, and snippets.

@dtsdwarak
Last active September 26, 2015 18:38
Show Gist options
  • Save dtsdwarak/d50b256f6b14bd06a4bf to your computer and use it in GitHub Desktop.
Save dtsdwarak/d50b256f6b14bd06a4bf to your computer and use it in GitHub Desktop.
Mongo to Couch
#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