I am trying to update an array field in an subdocument array in my collection. My collection looks like this:
{
_id:"1",
employees:[{ eid:"2",
ename:"test",
is_user:true
},
{ eid:"3",
ename:"test2",
is_user:true
}
]
}
I am trying to update the is_user status and am trying it the following way:
db.users.update({_id:"1","employees.eid":"2"},{$set:"employees.$.is_user":true},true);
I also tried :
db.users.update({_id:"1","employees.$.eid":"2"},{$set:"employees.$.is_user":true},true);
But when I run a find, for the query:
db.users.find({_id:"1","employees.eid":"2"});
it still gives me nothing. Can anybody help me on this ? Thank you..