Why is Mongoose showing the deprecated warning after I have set the promise library?
Countless posts (example #1, example #2, etc.) say to set mongoose.Promise = global.Promise;
to resolve this warning. I have even done it myself in the past! However, nothing I do prevents Mongoose from complaining about the promise library:
(node:54561) DeprecationWarning: Mongoose: mpromise (mongoose's default
promise library) is deprecated, plug in your own promise library instead:
http://mongoosejs.com/docs/promises.html
I'm using v4.8.7 with the following code:
var bodyParser = require('body-parser'),
config = require('./config'),
data = require('./data'),
express = require('express')
mongoose = require('mongoose'),
routes = require('./routes');
mongoose.Promise = global.Promise;
var db = mongoose.connection;
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(routes);
db.once('open', function() {
console.log('Database connected!');
data.seeds.doSeed(function(){
app.listen(3000, function() {
console.log('Mongo example listening on port 3000!');
});
});
});
mongoose.connect(config.db.uri, config.db.options);