mongoose之findOneAndUpdate方法之代碼示例

categoryModel.findOneAndUpdate({name:{$in:req.body.categorys}},{$inc:{total:1}},function(err){
          if (err) return console.log(err);
          res.json({status:'ok',msg:'發佈成功'})
        })

//在category集合裏查找name在json

req.body.categorys

這個數組裏的文檔,將查找到的全部文檔的total字段都自增1數組

相關文章
相關標籤/搜索