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

前端 未结 5 1119
野性不改
野性不改 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 19:06

    First, mongoose uses Promise for Async applications. In new versions it can be:

    mongoose.connect("URL").then("what you need to happen after the connection is done").catch("when the error happened")
    

    Therefore, I used promise and global to use mongoose anywhere as Async when writing mongoose.

提交回复
热议问题