2017-04-06 30 views
2

我使用MEAN堆棧每次我保存的用戶我得到這樣的警告時(節點:2157)DeprecationWarning:貓鼬:mpromise(貓鼬的默認承諾庫)已被棄用,插上自己的諾言庫,而不是

(節點:2157)DeprecationWarning:貓鼬:mpromise(貓鼬的默認承諾庫)已被棄用,插上自己的諾言庫,而不是:http://mongoosejs.com/docs/promises.html

這是我保存用戶數據

user.save(function(err, user) { 
    if (err) return res.status(500).send({message: There was an error creating user. Please try again later: ${err}}) 
    return res 
     .status(200) 
     .send({ message: 'user successfully created' }); 
    }); 

我該怎麼辦刪除警告在控制檯?

回答

1

你應該看看this答案。

你需要一個插件庫諾(Q,藍鳥,該ES6一個......)

bluebird

mongoose.Promise = require('bluebird'); 

對於ES6:

mongoose.Promise = global.Promise; 

更多信息,您可以在docs找到。