The title is a little bit hard to understand the first time, so here is an example. I use mongodb and have data like this :
id: String
timestamp: String
steps: [{
action: 1,
timestamp: String
}, {
action: 2,
timestamp: String
}, ...
]
I would like to add a new field to each step, let's say bot: false
.
I tried an update like :
{ $set: { 'steps': { 'bot': false } } }
However this replaced the whole step, losing action/timestamp. I also tried :
{ $set: { 'steps.bot': false } }
This didn't work either, because steps is an array.
I also looked at the $each modifier, however it doesn't seem to work with $set.
Any idea ? Thanks