So I'm trying to push an object into a nested array for all matching records.
here is the basic structure:
{
client:'client_name',
items:[
{
name:'item_one',
status:'LIVE',
period:[
{
name:'dec-15',
owed: 20
}
]
}
]
}
and what I'm trying to do is push an array into items.period for all live items.
here is the cli I used:
db.records.update({'items.status':'LIVE'},{$push:{'items.$.period':{name:'Aug-15',owed:20}}},{multi:true});
this works but only for the first record. I'm sure I'm screwing something up with the positional operator but I don't know what.