Skip to content

Instantly share code, notes, and snippets.

@Samstiles
Created August 18, 2014 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Samstiles/556a6c22e1827523ef31 to your computer and use it in GitHub Desktop.
Save Samstiles/556a6c22e1827523ef31 to your computer and use it in GitHub Desktop.
/**
* Bootstrap
* (sails.config.bootstrap)
*
* An asynchronous bootstrap function that runs before your Sails app gets lifted.
* This gives you an opportunity to set up your data model, run jobs, or perform some special logic.
*
* For more information on bootstrapping your app, check out:
* http://links.sailsjs.org/docs/config/bootstrap
*/
module.exports.bootstrap = function(cb) {
// It's very important to trigger this callack method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
async.parallel([
function(){
Form.find().exec(function(err, results){
if(results.length === 0){
Form.create({show_rif: true, show_rai: true, show_rti: true}).exec(function(){
});
}
});
},
function(){
Organization.find().exec(function(err, results){
if(results.length === 0){
var orgs = getOrganizations();
async.each(orgs, function(org, callback){
Organization.create(org)
.exec(function(err, results){
callback();
});
}, function (err, results) {
cb();
});
}
cb();
});
}
], function(err, status){
cb();
});
function getOrganizations(){
organizations = [
{name: 'Atlantic Cancer Research Institute', contact_email: 'foo@foo.com'},
{name: 'Collège communautaire du Nouveau-Brunswick', contact_email: 'foo@foo.com'},
{name: 'Huntsman Marine Science Center', contact_email: 'foo@foo.com'},
{name: 'Mount Allison University', contact_email: 'foo@foo.com'},
{name: 'New Brunswick Community College', contact_email: 'foo@foo.com'},
{name: 'Saint Thomas University', contact_email: 'foo@foo.com'},
{name: 'University of New Brunswick', contact_email: 'foo@foo.com'}
];
return organizations;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment