I have a question.
I wanted to start 2 db calls and then continue the promise chain.
A rather hackish way i did was to start the promise like this:
db.Model.find().then(function() {
return [
firstcall,
secondcall
]
}).spread(function(resultFromFirstCall, resultFromSecondCall) {
//do something once both calls completed
});
Is it alright to start the promise chain with an empty db call? Or is there a better way.
I know I can bring in that async library but I see this as a cleaner approach, if there are no performance effect to making the empty db.Model.find() call.
I'm not sure what an empty find call would do here since I have never used SequelizeJS, however I'm pretty sure that what you're looking for is probably Promise.join
Promise.join( firstCall, secondCall, function( firstResult, secondResult ) {
// Whatever
});
After some time, I found a even better way to do it.
Promise.resolve().then(function() {
return [
firstCall(),
secondCall()
];
}).spread(function(resultFromFirst, resultFromSecond) {
//do something with resultFromFirst and resultFromSecond
});