Audel O. Gutierrez Audel O. Gutierrez - 10 months ago 949
Node.js Question

(node:3341) DeprecationWarning: Mongoose: mpromise

I'm triyng to develop a class on the top of mongoose with my custom methods, so I extendes the mongoose with my own class but when I invoke create a new car method it works but its strip and error, here I let you see what I'm trying to do.

I'm getting this warning

(node:3341) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead:

after I do

carName: 'jeep',
availableSeats: 4,
}, callback);

driver is an instance of Driver class

const carSchema = new Schema({
carName: String,
availableSeats: Number,
createdOn: { type: Date, default: },
const driverSchema = new Schema({
email: String,
name: String,
city: String,
phoneNumber: String,
cars: [carSchema],
userId: {
type: Schema.Types.ObjectId,
required: true,
createdOn: { type: Date, default: },
const DriverModel = mongoose.model('Driver', driverSchema);

class Driver extends DriverModel {
getCurrentDate() {
return moment().format();
create(cb) {
// save driver
this.createdOn = this.getCurrentDate();;
remove(cb) {
_id: this._id,
}, cb);
createCar(carData, cb) {;;
getCars() {

any thoughts about what Im doing wrong?

Answer Source

Here's what worked for me to clear up the issue, after reading docs:

The example in the doc is using the bluebird promise library but I chose to go with native ES6 promises.

In the file where I'm calling mongoose.connect:

mongoose.Promise = global.Promise;