I am trying to set up my MongoDB database using mongoose but getting a deprecated warning "Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"
Here is my code for server.js file below:
var mongoose = require('mongoose');
mongoose.promise = require('bluebird');
// mongoose.promise = global.promise;
mongoose.connect('mongodb://localhost:27017/TodoApp');
var Todo = mongoose.model('Todo', {
text: {
type: String
},
completed: {
type: Boolean
},
completedAt: {
type: Number
}
});
var newTodo = new Todo({
text: 'Cook dinner'
});
newTodo.save().then((doc) => {
console.log('Saved todo', doc);
}, (e) => {
console.log('Unable to save todo')
});
I already tried to install bluebird and to use it as my third party promise but still getting the same error message.
You should use
You are using
Also I think you are using older version of nodejs. I use node js 8 & mongoose takes global.Promise by default as nodejs 8 comes with native Promise.