LearnBoost / express-mongoose

Plugin for easy rendering of Mongoose async Query results.
MIT License
450 stars 30 forks source link

Different promise implementations are not accepted #23

Open jrvidal opened 10 years ago

jrvidal commented 10 years ago

If I try to do something like:

res.send(query.exec().then(function(data) {
    var formattedData = format(data);
    return data;
}));

the plugin does not work, since it is checking for the mongoose promise implementation in particular, and the then method returns a MPromise. It would be nice to be able to interoperate with thenables in general or, at least, to redefine mongoose.Promise#then to return mongoose.Promise instances.

aheckmann commented 10 years ago

instead of using instanceof checks for Promises we could add an isPromise() function which accepts an arg and checks if 'function' == typeof arg.then. pull request?