Mongoose - Why we make “mongoose.Promise = global.Promise” when setting a mongoose module?

前端 未结 5 1133
野性不改
野性不改 2020-12-29 18:04

I\'m working with Mongoose. I have seen a lot of developers make the following command:

mongoose.Promise = global.Promise;

Then I was curi

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 18:54

    Mongoose maintainer here. If you're using Mongoose 5, please remove mongoose.Promise = global.Promise;. That line was used to address the below deprecation warning with promises in Mongoose 4:

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

    It does nothing in Mongoose 5. You should only use mongoose.Promise in Mongoose 5 if you want to use your own promise library with Mongoose, like Bluebird or Q.

    There's also a little more about mongoose.Promise here: https://masteringjs.io/tutorials/mongoose/promise#the-mongoosepromise-property

提交回复
热议问题