I am trying to update some matched elements within an array in a mongodb document.
I want to update all the comments.$index.author from chao to tom, but I can't figure out the syntax.
Here's what I want to do in pseudo-json.
Before:
{
 "author" : "lily",
 "contents" : "watch movive",
 "comments" : [
             {
                 "comment" : "good",
                 "author" : "chao",
                 "votes" : 0
             },
             {
                 "comment": "so so",
                 "author": "chao",
                 "votes": 3
             },
             ………………,
             {
                 "comment": "bad",
                 "author": "yong",
                 "votes": -1
             },
         ]
}
After:
{
"author" : "lily",
"contents" : "watch movive",
"comments" : [
             {
                 "comment" : "good",
                 "author" : "tom",
                 "votes" : 0
             },
             {
                 "comment": "so so",
                 "author": "tom",
                 "votes": 3
             },
             ………………,
             {
                 "comment": "bad",
                 "author": "yong",
                 "votes": -1
             },
         ]
 }
 
    