Mongoose: Use native promises as default

Created on 27 Apr 2015  Â·  11Comments  Â·  Source: Automattic/mongoose

Use native promises (node v 0.12+) as default. For old versions of node.js use old promise library

Most helpful comment

Two years since this issue guys, are there any updates?

All 11 comments

I agree. I use node 0.12 and can't use catch() without hack

This will have to wait for 5.0, IMO qualifies as backwards-breaking. I agree with the suggestion though.

@Jokero – what is the hack you used? Fair enough that this is still a work in progress, but in the meantime it would be great if the ES6 compatibility page on the mongoose website could be updated. It currently states:

Documents in ES6

Asynchronous document functions return promises, and so are compatible with the ES6 yield keyword and libraries like co.

Given that the document is titled to suggest it is about support of ES6-native features, the use of the unqualified phrase 'promises' to me strongly implied native promises, particularly now that they are supported without any flags on the latest stable node 0.12.x (and consequently wrote a fair amount of code on that assumption before realising it was incorrect).

If you click through the link, it does indeed lead to the mpromises website, but in the meantime perhaps the page could be updated to explicitly state that only mpromises are supported right now (perhaps by just replacing 'promises' with 'mpromises') to avoid any confusion.

@kencoken, I use it:

require('mongoose/node_modules/mpromise').prototype.catch = function(onReject) {
    return this.then(undefined, onReject);
};

See #2688

@Jokero thanks for this! That's really helpful for now :+1:

Two years since this issue guys, are there any updates?

No updates yet. Stay tuned :+1:

@vkarpov15 Can we please remove lib/promise.js and use native Promises? We can put in engines of Mongoose's package.json for Node v6.4.0+.

Yep that's the plan :+1:

Fixed in 5.0 branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

saudelog picture saudelog  Â·  79Comments

nparsons08 picture nparsons08  Â·  40Comments

fundon picture fundon  Â·  42Comments

wshaver picture wshaver  Â·  50Comments

adeelzaman picture adeelzaman  Â·  82Comments