Something like this:
myschema.pre('save', function () {
return new Promise((resolve. reject) => {
...
});
};
reasons:
Node 4.0 has yield
support, and it's finally comfortable to use promises/co/... everywhere.
I'd really love to use the composition module that koa's been using going forward for mongoose middleware. Or just plain old koa-compose. However, to do that, we'd have to completely drop support for node 0.x, which is a bit scary. Open to discussion :)
From the other hand... it's unusual to use different coding styles in the same project. So, it's possible to do configurable hooks engine, and avoid pain of combining different hooks signatures in the same time:
var mongoose = require('mongoose').default({ hooker: 'kareem' })
Mongoose currently supports back to node 0.10. Dropping support for node 0.10 and 0.12 would qualify as backwards-breaking - if require('mongoose');
fails in node 0.10, that's a big change.
Configurable hooks engine will have some pain points: we still haven't been able to rip out the archaic hooks module successfully yet, so until that's done we can't even use a consistent hooks module, let alone make it configurable...
Are there any plans for 5.0 phase start? I understand all concerns about stability and see a long tail of minor issues for polishing. But that can be endless. When are you going to start "breaking everything" :) ?
No concrete plans, probably late 2016, still plenty of additive changes that can be made :)
Hi @vkarpov15 @puzrin Any news?
@mahnunchik not yet.
Fixed in 5.0 branch
Most helpful comment
Fixed in 5.0 branch