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

前端 未结 5 1118
野性不改
野性不改 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 18:45

    we used just in the point when we want to get connected in to MongoDB database :

    var mongoose = require('mongoose');
    
    var mongoDB = ' database url ';
    
    mongoose.connect(mongoDB);
    
    mongoose.Promise = global.Promise;
    
    mongoose.connection.on('error',console.error.bind(console, 'MongoDB connection error:'));
    

    you need to create schema and do your own model after

提交回复
热议问题