Solvedmongoose Deprecation Warning

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?

52 Answers

✔️Accepted Answer

I solved that warning doing

mongoose.Promise = global.Promise;

Right before calling mongoose.connect

// connect to mongo function
core.connect = function connect(opts) {
  mongoose.Promise = global.Promise;
  return mongoose.connection;

Other Answers:

This works! Before mongoose.connect(MONGO_URI); add mongoose.Promise = global.Promise;

@protoEvangelium wait a minute, did you try this?

const mongoose = require('mongoose')
mongoose.Promise = global.Promise // <--
const Schema = mongoose.Schema
const UserSchema = new Schema({
  name: String,
const User = mongoose.model('user', UserSchema)
module.exports = User

if you create a model from a mongoose instance who's promise wasn't redefined - every query on this model would throw the warning.

I'm getting it but I'm only getting it where I save a object then modify it in the callback and save again

as a fellow Russian speaker I apologize for the behavior this lesser being has displayed an urge you not to translate what it has written here.

Related Issues:

mongoose Deprecation Warning
I solved that warning doing Right before calling mongoose.connect I'm getting this warning after I d...
mongoose Saving a model fails with mongo error: MongoError: Unknown modifier: $pushAll
Well that's one problem mongodb 3.5 is an unstable dev release and should not be used ...
mongoose Is not a function ERROR - this.isModified is not a function
You are using an arrow operator for the callback which changes the scope of this If you define a reg...
mongoose No retries are made after "failed to connect on first connect"
For anyone wanting auto-reconnection when first connect fails By default mongoose throws an Error if...
mongoose Need to check if password field has been modified in pre findOneAndUpdate
I'm currently using this solution and it works You don't need to execute another query. ...
mongoose Allow import { model } from mongoose
+1 Currently this doesn't work: It's common when user wants to import variables from module without ...
mongoose the options [user] and [pass] is not supported when using with useMongoClient: true
Working on getting support for this in the mongodb driver with the above PR ☝️ For now as a workarou...
mongoose Property 'Buffer' does not exist on type 'typeof globalThis'.
Think explicitly adding @types/node should work as a temp workaround npm i --save-dev @types/node@^1...
mongoose server/replset/mongos options are deprecated => documentation?
The message says that all of the server replset and mongos options have been moved to the top level ...
mongoose Way to handle mongoose.connect() error in promise catch handler
Use the callback of mongoose.connect to catch any error during the connection You can start you serv...
mongoose Handle cast error on find when objectId is invalid
This is expected behavior and your way of handling the error is mostly correct Do you want to reques...
mongoose mongoose 5.4.20 does not overwrite all properties in a nested subdocument.
I have the same problem using Object.assign() Do you want to request a feature or report a bug? Bug ...