Database

[{_id:"should match","profileSpherestatus":[{"idf":"B002","completedPercentage":100},{"idf":"B003","completedPercentage":90},{"idf":"B004","completedPercentage":100}],"myGratifications":[{"idb":"B003","gratification":20},{"idb":"B004","gratification":30}]},{_id:"should NOT match example 1","profileSpherestatus":[{"idf":"B002","completedPercentage":100}],"myGratifications":[{"idb":"B002","gratification":20}]},{_id:"should NOT match example 2","profileSpherestatus":[{"idf":"B003","completedPercentage":90}],"myGratifications":[{"idb":"B003","gratification":20}]},{_id:"should NOT match example 3","profileSpherestatus":[{"idf":"B002","completedPercentage":100}],"myGratifications":[{"idb":"B002","gratification":20},{"idb":"B003","gratification":20}]}]

Query

db.collection.update({/** match criteria*/"$and":[/** other filter criteria START*/{/** as an example*/"_id":{"$regex":".*"}},/** other filter criteria END* ACTUAL filter criteria to update or not*/{"profileSpherestatus":{"$elemMatch":{"idf":"B002","completedPercentage":100}}},{"myGratifications":{"$not":{"$elemMatch":{"idb":"B002"}}}}]},[/** update operations*/{"$set":{"myGratifications":{"$concatArrays":["$myGratifications",[{"idb":"B002","gratification":10}]]}}}],{multi:true})

Result