Thursday 4 May 2017

How can I automatically replace mpromise with bluebird for every model in my application?

I have replaced mpromise with bluebird successfully using this documentation: http://mongoosejs.com/docs/promises.html. However, it doesn't seem like good practice to have to constantly put mongoose.Promise = require('bluebird') in every file where I need mongoose (mostly the models). I've tried using the following module in my application instead of mongoose from node-modules.

import mongoose from 'mongoose';
import Promise from 'bluebird';

mongoose.Promise = Promise;

export default mongoose;

But the promises returned are still mpromise style. How do I efficiently replace the promise library of mongoose in one place so that it propagates throughout the rest of my application?



via Jordan

No comments:

Post a Comment