node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Add jquery style .when support to mongoose promise object. Requires mongoose v3.6.1 or higher, no other requirements.

Use exactly like jquery.when on which this code is based.

Promise.when() returns a Mongoose promise object.

var mongoose = require('mongoose');
var Promise = mongoose.Promise;
var p1 = Users.find();
var p2 = Animals.find();
Promise.when(p1, p2).addBack(function(err, users, animals) {

See unit tests for for more usage examples.