大佬教程收集整理的这篇文章主要介绍了node.js – (node:3341)DeprecationWarning:Mongoose:mpromise,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我收到这个警告@H_450_7@
(node:3341) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated,plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
后我做@H_450_7@
driver.createCar({ carName: 'jeep',availableSeats: 4,},callBACk);
const carscheR_957_11845@a = new scheR_957_11845@a({ carName: String,availableSeats: number,createdOn: { type: Date,default: Date.Now },}); const driverscheR_957_11845@a = new scheR_957_11845@a({ email: String,name: String,city: String,phonenumber: String,cars: [carscheR_957_11845@a],userId: { type: scheR_957_11845@a.Types.ObjectId,required: true,}); const DriverModel = mongoose.model('Driver',driverscheR_957_11845@a); class Driver extends DriverModel { getCurrentDate() { return moment().format(); } create(cb) { // save driver this.createdOn = this.getCurrentDate(); this.save(cb); } remove(cb) { super.remove({ _id: this._id,cb); } createCar(carData,cb) { this.cars.push(carData); this.save(cb); } getCars() { return this.cars; } }
任何想法,我做错了什么?@H_450_7@
在doc中的例子是使用bluebird promise库,但我选择了与原生的ES6承诺。@H_450_7@
在我@L_886_3@mongoose.connect的文件中:@H_450_7@
@H_453_9@mongoose.Promise = global.Promise; mongoose.connect('mongodb://10.7.0.3:27107/data/db');
[编辑:感谢@SylonZero在我的答案带来了性能缺陷。由于这个答案是如此之大,我觉得有责任做这个编辑,并鼓励使用蓝鸟,而不是本土承诺。请阅读他们更教育的答案。 ]]@H_450_7@
以上是大佬教程为你收集整理的node.js – (node:3341)DeprecationWarning:Mongoose:mpromise全部内容,希望文章能够帮你解决node.js – (node:3341)DeprecationWarning:Mongoose:mpromise所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。