If I have a collection mycoll of documents like this :
{
vals : [10, 11]
}
where the length of the vals array is NOT fixed.
is there a way to $inc ALL the elements in the vals array with one command ?
I've tried
db.mycoll.update({}, { $inc : { vals : 5 }}, { multi : true })
// error cannot $inc non-number
db.mycoll.update({}, { $inc : { vals.$ : 5 }}, { multi : true })
// error must specify a field
and the goal is to get
{
vals : [15, 16]
}
without having to fetch each document, copy and update the array, then save the updated array back to the document...
my thanks in advance for any ideas !