0

Data:

{
    name : "a",
    regists:[
       {
           name : "1",
           isCancel: false
       },
       {
           name : "2",
           isCancel: false
       }
  ]
}

Operation:

model.update({
    'name':'a',
    'regists.isCancel' : false
},{
    $set :{
        'regists.$.isCancel' :true
    }
})

It's working when I run it the first time, but nothing changes when I run it afterwards.

chridam
  • 100,957
  • 23
  • 236
  • 235
  • set multi to true if you want to update multiple documents based on the condition. Here is the syntax for update db.collection.update( , , { upsert: , multi: , writeConcern: } ); Hope it helps – Abdul Hamid Jul 28 '16 at 08:34
  • model.update({ 'name':'a', 'regists':{ $elemMatch :{ isCancel : false, } } },{ $set :{ 'regists.$.isCancel' :true } }) – Guan Jarvin Jul 28 '16 at 08:41

0 Answers0