Created
March 12, 2013 18:54
-
-
Save lvnilesh/5145819 to your computer and use it in GitHub Desktop.
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
// This gist is meant to help you load a json datafile into a Meteor application. More specifically, it's useful to migrate or bootstrap a Mongo datacollection. | |
// The easiest way to do this task is to open up three command shell windows. | |
// As a few of the commands will take over the command shell and direct their output to stdout. | |
// first, export your data to a file | |
// data.json | |
// run mongod so we can create a staging database | |
// not that this is a separate instance from the meteor mongo and minimongo instances | |
mongod | |
// import the json data into a staging database | |
// jsonArray is a useful command, particularly if you're migrating from SQL | |
mongoimport -d staging -c assets < data.json --jsonArray | |
// navigate to your application | |
cd myappdir | |
// run meteor and initiate it's database | |
meteor | |
// connect to the meteor mongodb | |
meteor mongo --port 3002 | |
// copy collections from staging database into meteor database | |
db.copyDatabase('staging', 'meteor', 'localhost'); | |
// shut down the staging database | |
Ctrl-C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment