When to use denodeify/nfbind vs nfcall/ninvoke When to use denodeify/nfbind vs nfcall/ninvoke mongoose mongoose

When to use denodeify/nfbind vs nfcall/ninvoke


Mongoose (at least in the last year or so) already returns promises that are Promises/A+ spec complaint.

You don't need to wrap them in Q promises unless you have to. Q, being promises/A+ complaint itself will gladly consume these promises and interop with them for you.

You can, for example use Q.all on three calls of find(...).exec().

 Q.all([     User.find({route: foo}).exec(), // Q will detect that the values are 'thenable'     User.find({route: bar}).exec(), // and will automatically assimilate them into a      User.find({route: baz}).exec()  // Q promise on its own. No explicit action needed.]).spread(function(res1,res2,res3){     // access results.});