{"id":701,"hash":"b38a3617e08e268afadf3bfda4ff1b311060da00f7c43148b8aa1fcf6995e6f2","pattern":"(node:3341) DeprecationWarning: Mongoose: mpromise","full_message":"I'm trying to develop a class on the top of the mongoose with my custom methods, so I extended the mongoose with my own class but when I invoke to create a new car method it works but its strip and error, here I let you see what I'm trying to do.\n\nI'm getting this warning\n\n(node:3341) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html\n\nafter I do\n\ndriver.createCar({\n      carName: 'jeep',\n      availableSeats: 4,\n    }, callback);\n\ndriver is an instance of Driver class\n\nconst carSchema = new Schema({\n  carName: String,\n  availableSeats: Number,\n  createdOn: { type: Date, default: Date.now },\n});\nconst driverSchema = new Schema({\n email: String,\n name: String,\n city: String,\n phoneNumber: String,\n cars: [carSchema],\n userId: {\n   type: Schema.Types.ObjectId,\n   required: true,\n },\ncreatedOn: { type: Date, default: Date.now },\n});\nconst DriverModel = mongoose.model('Driver', driverSchema);\n\nclass Driver extends DriverModel {\n  getCurrentDate() {\n  return moment().format();\n}\ncreate(cb) {\n  // save driver\n  this.createdOn = this.getCurrentDate();\n  this.save(cb);\n}\nremove(cb) {\n  super.remove({\n  _id: this._id,\n }, cb);\n}\ncreateCar(carData, cb) {\n  this.cars.push(carData);\n  this.save(cb);\n}\ngetCars() {\n  return this.cars;\n }\n}\n\nany thoughts about what Im doing wrong?","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"Here's what worked for me to clear up the issue, after reading docs:\nhttp://mongoosejs.com/docs/promises.html\n\nThe example in the doc is using the bluebird promise library but I chose to go with native ES6 promises.\n\nIn the file where I'm calling mongoose.connect:\n\nmongoose.Promise = global.Promise;\nmongoose.connect('mongodb://10.7.0.3:27107/data/db');\n\n[EDIT: Thanks to @SylonZero for bringing up a performance flaw in my answer. Since this answer is so greatly viewed, I feel a sense of duty to make this edit and to encourage the use of bluebird instead of native promises. Please read the answer below this one for more educated and experienced details. ]","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/38138445/node3341-deprecationwarning-mongoose-mpromise","votes":91,"created_at":"2026-04-19T04:51:30.408085+00:00","updated_at":"2026-04-19T04:51:30.408085+00:00"}