1//Example "users" collection:
2
3{
4 name: "Jim",
5 friends: [
6 {name: "Pam"},
7 {name: "Michael"}
8 ]
9}
10
11//Will be:
12
13{
14 name: "Jim",
15 friends: [
16 {name: "Pam", active: true},
17 {name: "Michael", active: true}
18 ]
19}
20
21//For every user inside "users"
22
23db.getCollection('users').update({}, {"$set": {"friends.$[].active": true}}, {multi: true})