I have a document structure like this:
{
    "_id" : "1234",           
    "name" : "foo",  
    "bar" : [  
        {"some0":"value0"},  
        {"some1":"value1"},           
        {"some2":"value2"}
    ]   
}
And i just want to delete Objects in the nested "bar" array by its indices within the array e.g. i have an array of indices like [0,2] which should delete "some0" and "some2" from the array.
I'm aware, that Mongo currently has no way to delete values by its index atomically and usually this is used instead:
db.lists.update({}, {$unset : {"bar.0" : 1 }}) 
db.lists.update({}, {$pull : {"bar" : null}})
Question: Is there a more efficient way to do this if my array of to be deleted indices gets quite large (>100) than looping over them manually and do the 2 modifications for each of them.
 
     
     
    