I have documents in my collection that have a top level field called ‘foo’ which is an array of hashes. I need to be able to go through all my documents and find where db.mycollection.foo contains a hash with the sub property ‘name’ equal to ‘bar’. When that match is done, I need to update a top level field called ‘hit’ to the value 1.
So just to reiterate the collection is called mycollection. foo is a field that is of type array and contains hashes where each hash has a field called name. If any of the hashes contain name == ‘bar’, I need to perform the update.
I believe what you want is: