-
-
Save robwormald/ae9131ed1a389fe87b94 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
//bluebird promise lib >>>> anything | |
var q = require('bluebird'); | |
module.exports.bootstrap = function(cb) { | |
//returns a promise | |
var findOrCreateForm = function(){ | |
return Form.find().then(function(forms){ | |
if(forms.length > 0){ | |
return forms; | |
} | |
return Form.create(); | |
}) | |
} | |
var findOrCreateOrgs = function(){ | |
return Organization.find().then(function(orgs){ | |
if(orgs.length >0){ | |
return orgs; | |
} | |
return getOrganizations().map(function(org){ | |
return Organization.create(org); | |
}) | |
}) | |
} | |
q.all([findOrCreateForm,findOrCreateOrgs]).then(function(forms,orgs){ | |
cb(); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment