question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecation Warning

See original GitHub issue

I’m getting this warning

(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

after I do

driver.createCar({
          carName: 'jeep',
          availableSeats: 4,
        }, callback);

driver is an instance of Driver class

const carSchema = new Schema({
  carName: String,
  availableSeats: Number,
  createdOn: { type: Date, default: Date.now },
});
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: Date.now },
});
const DriverModel = mongoose.model('Driver', driverSchema);

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

any thoughts about what Im doing wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:43
  • Comments:79 (5 by maintainers)

github_iconTop GitHub Comments

358reactions
saudelogcommented, Jul 4, 2016

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;
  mongoose.connect(`mongodb://${opts.server}:${opts.port}/${opts.db}`);
  return mongoose.connection;
};
19reactions
OpakAlexcommented, Feb 1, 2017

So stupid issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does DeprecationWarning mean when running Python
removing is danger because user may used that and if a developer want to remove a thing first have to notify others to...
Read more >
warnings — Warning control — Python 3.11.1 documentation
DeprecationWarning. Base category for warnings about deprecated features when those warnings are intended for other Python developers (ignored by default, ...
Read more >
Dealing with Deprecation Warnings - Java Cookbook [Book]
As a general rule, when something has been deprecated, you should not use it in any new code and, when maintaining code, strive...
Read more >
Deprecation warnings in legacy JavaScript code using ...
In software development, deprecation is usually associated with changes in the APIs of libraries and frameworks. Deprecation warnings are ...
Read more >
Python deprecation - DEV Community ‍ ‍
To let the warning refer to the caller, so you know exactly where you use deprecated code, you have to set stacklevel=2 ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found