How can we update all elements that match the condition in all arrays in one operation
***we filter out all documents whose arrays has element equal to or greater than 100
pradb>db.t1226_1.find()
{ "_id" : 1, "grades" : [ 95, 92, 90 ] }
{ "_id" : 2, "grades" : [ 98, 100, 102 ] }
{ "_id" : 3, "grades" : [ 95, 110, 100 ] }
pradb>db.t1226_1.find({grades:{$gte:100}});
{ "_id" : 2, "grades" : [ 98, 100, 102 ] }
{ "_id" : 3, "grades" : [ 95, 110, 100 ] }
***Now we need to update all elements equal to or greater than 100 to 333 and we invoke the following update operations
pradb>db.t1226_1.update({grades:{$gte:100}},{$set:{"grades.$":333}},{multi:true})
WriteResult({ "nMatched" : 2, "nUpserted" : 0, "nModified" : 2 })
***From the result we can see that only the first element which is equal to or greater than 100 in each array is updated while the rests remains unchanged
pradb>db.t1226_1.find()
{ "_id" : 1, "grades" : [ 95, 92, 90 ] }
{ "_id" : 2, "grades" : [ 98, 333, 102 ] } <---only 100 is updated to 333, 102 remains unchanged
{ "_id" : 3, "grades" : [ 95, 333, 100 ] } <---only 110 is updated to 333,100 remains unchanged
If we intend to update all elements which are greater than 100 in one operation, how can I do it?