Database
[{"userId":"10000001","name":"Josh","booksBought":[{"booktitle":"harry potter","quantity":1},{"booktitle":"game of thrones","quantity":2}]},{"userId":"10000002","name":"Carl","booksBought":[{"booktitle":"lord of the rings","quantity":4}]}]
Query
db.collection.update({"userId":{$in:["10000001","10000002"]}},[{"$set":{"booksBought":{"$cond":{"if":{"$in":["harry potter","$booksBought.booktitle"]},"then":"$booksBought","else":{"$concatArrays":["$booksBought",[{"booktitle":"harry potter","quantity":0}]]}}}}},{"$set":{"booksBought":{"$map":{"input":"$booksBought","as":"bb","in":{"$cond":{"if":{$eq:["harry potter","$$bb.booktitle"]},"then":{"$mergeObjects":["$$bb",{"quantity":{"$add":["$$bb.quantity",10]}}]},"else":"$$bb"}}}}}}],{multi:true})