Created
August 18, 2014 23:02
-
-
Save Samstiles/556a6c22e1827523ef31 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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: '[email protected]'}, | |
{name: 'Collège communautaire du Nouveau-Brunswick', contact_email: '[email protected]'}, | |
{name: 'Huntsman Marine Science Center', contact_email: '[email protected]'}, | |
{name: 'Mount Allison University', contact_email: '[email protected]'}, | |
{name: 'New Brunswick Community College', contact_email: '[email protected]'}, | |
{name: 'Saint Thomas University', contact_email: '[email protected]'}, | |
{name: 'University of New Brunswick', contact_email: '[email protected]'} | |
]; | |
return organizations; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment