I currently have a mongo object set up like so.
{
"_id" : "FtFKS23swBSEtEJAK",
"active_users" : [
{
"user" : {
"profile" : {
...
}
},
"maxMessages" : 25
},
{
"user" : {
"profile" : {
...
}
}
"maxMessages" : 25
}
],
"display_name" : "Testing"
}
Now, I am trying to run a mongo query that will go through the embedded active users and increment the maxMessages by a given value.
I cant seem to get it right though.
This is my failed attempt
activeUsersLength = Rooms.findOne({}).active_users.length
for i in [0..activeUsersLength-1]
Rooms.update({_id: room}, {$inc: {'active_users.' + i + '.maxMessages': 1}})