在使用collection.find我查询文档时,我开始在控制台中收到以下警告
DeprecationWarning:不推荐使用collection.find选项[fields],将在以后的版本中删除
我为什么看到这个,我该如何解决这个问题?(可能的选择)
编辑:查询已添加
Session
.find({ sessionCode: '18JANMON', completed: false })
.limit(10)
.sort({time: 1})
.select({time: 1, sessionCode: 1});
Run Code Online (Sandbox Code Playgroud)
猫鼬版本5.2.9
尝试更新MongoDB文档获取弃用警告为
(节点:71307)[DEP0079]弃用警告:不推荐使用.inspect()对象的自定义检查功能
节点版本v10.5.0,db版本v3.6.5,Mongoose版本mongoose@4.1.12
Campground.findById(campgroundId, function(err, campground){
if(err){
console.log(err);
} else {
console.log(campground.celebrity);
Celebrity.create(celebrityData, function(err, celebrity){
if(err){
console.log(err);
} else {
//save comment
celebrity.save();
campground.celebrity.push(celebrity);
campground.save();
console.log(celebrity);
//req.flash('success', 'Created a comment!');
}
});
}
});
Run Code Online (Sandbox Code Playgroud)