(node:3341) DeprecationWarning: Mongoose: mpromise

后端 未结 8 1876
忘了有多久
忘了有多久 2020-11-27 11:19

I\'m trying to develop a class on the top of the mongoose with my custom methods, so I extended the mongoose with my own class but when I invoke to create a new car method i

8条回答
  •  时光说笑
    2020-11-27 11:53

    I think you have your answer but I use global.promise with error handling

    // MongoDB connection
    mongoose.Promise = global.Promise;
    
    var promise = mongoose.connect('mongodb://localhost:27017/test_db', {
      useMongoClient: true,
    });
    
    promise.then(function(db) {
        console.log("Connected to database!!!");
    }, function(err){
        console.log("Error in connecting database " + err);
    });
    

提交回复
热议问题