Skip to content

Instantly share code, notes, and snippets.

@Sequoia
Created July 24, 2015 14:53
Show Gist options
  • Select an option

  • Save Sequoia/e0c435b4a6c2e4ff2187 to your computer and use it in GitHub Desktop.

Select an option

Save Sequoia/e0c435b4a6c2e4ff2187 to your computer and use it in GitHub Desktop.
automigrate example: Create some dummy data for development (obv. don't do this on prod)
//server/boot/create-some-data.js
module.exports = function(app) {
//@TODO: check ENV for NODE_ENV!==PRODUCTION
//data sources
var mongoDs = app.dataSources.mongoDs;
function createReviewers(cb) {
mongoDs.automigrate('Reviewer', function(err) {
if (err) return cb(err);
var Reviewer = app.models.Reviewer;
Reviewer.create([
{email: 'foo@bar.com', password: 'foobar'},
{email: 'john@doe.com', password: 'johndoe'},
{email: 'jane@doe.com', password: 'janedoe'}
], cb);
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment