Mongodb更新数组元素不会工作

时间:2016-11-04 21:49:10

标签: mongodb mongoose mongodb-query

我的json in db like this =

_id:21321213123, // req.body.analizId
updatedAt:...,
createdAt:...,
uploadedPhotos: [
   {
      photoId:12321311,
      isDeleted: false
   },
   ...
]

我的查询是

update({_id: req.body.analizId, "uploadedPhotos.photoId":req.body.id}, {$set:{"uploadedPhotos.$.isDeleted":true}}).exec(function(err, d){ console.log(d)});

我想更新uploadPhotos关联中的isDeleted字段,以及uploadPhotos数组中匹配的photoId 但代码不起作用 我怎么能这样做?

0 个答案:

没有答案