-
-
Save kim3er/6594588 to your computer and use it in GitHub Desktop.
Example of parallel Mongoose execution.
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
var performers; | |
performers = {}; | |
async.parallel({ | |
conductor: function(callback) { | |
return conductor.find({}, function(err, result) { | |
return callback(err, result); | |
}); | |
}, | |
soloist: function(callback) { | |
return soloist.find({}, function(err, result) { | |
return callback(err, result); | |
}); | |
}, | |
orchestra: function(callback) { | |
return orchestra.find({}, function(err, result) { | |
return callback(err, result); | |
}); | |
}, | |
chamber: function(callback) { | |
return chamber.find({}, function(err, result) { | |
return callback(err, result); | |
}); | |
} | |
}, function(err, performers) { | |
return res.json(performers); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're not going to do any processing on the result from mongoose, then there's no need to setup your own callback, just pass the async callback in to the find method, eg: