Is it possible to update a single document field in the Level3 array using $update and $elemMatch? I realize I cannot use the positional operator multiple times given this case and historically I've modified the Level2 nested document with the required deeper changes since these documents aren't very large. I'm hoping there is some syntax that makes it possible to update Level3 array documents using $elemMatch without knowing the position of the target document in the Level3 array or containing document in Level2.
Example:
db.collection.update({_id:'123', level2:{$elemMatch:{'level3.id':'bbb','level3.e1':'hij'}},{'level2.level3.createdDate':new Date()})
{
_id:'123',
f1:'abc',
f2:'def',
level2:[
{_
id:'aaa',
e1:'hij',
e2:'lmo'
level3:[
{
name:'foo',
type:'bar',
createdDate:'2013-3-28T05:18:00'
}]
},
{_
id:'bbb',
e1:'hij',
e2:'lmo'
level3:[
{
name:'foo2',
type:'bar2',
createdDate:'2013-3-28T05:19:00'
}]
}
]
}