foodModel.findByIdAndUpdate(foodId,{$set:{$inc:{f_count:1}}},{new:true},(err,data)=>{
if(err) throw err
console.log(data)
})
得到的效果
{
_id: new ObjectId("637b788d8670f65f40eaf8cf"),
picUrl: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.e5XHuuwPe3RpCjtWjqgC4wHaFj?w=219&h=180&c=7&r=0&o=5&pid=1.7',
f_name: '清炒小青菜',
f_price: '9.90',
f_discount: '7.8',
f_count: 3,
f_id: 9
}
我想要的效果是点击后f_count加一
当时就是一直没有更新。