I am trying to update a sub-document which is an array in mongodb using array index. Below is my code, is this possible ? or is their any othr way
arrayindex = 3;
Model.update({_id: ObjectId(id), 'array.userid' : ObjectId(userid)},{$set:{"array.arrayindex.points" :20, }}
i want to update 3rd object in subdocument.
Note : Above code is not working and when i use $ operator it updates only first matched object in array also arrayindex
variable can be any value dynamically known