Database
[{_id:12345,attributes:[{key:"email",value:"abc@efg.com"},{key:"name",value:"Somebody"}]}]
Query
db.collection.aggregate([{"$match":{/** whichever doc you're updating*/"_id":12345}},{/** unwrap the key value pairs to actual "key: value"*/"$set":{"attributes":{"$arrayToObject":{"$map":{"input":"$attributes","as":"i","in":{"k":"$$i.key","v":"$$i.value"}}}}}},{/** merge it with new/updated data*/"$set":{"attributes":{"$mergeObjects":["$attributes",{/** this is where you add new field and set existing ones*/"email":"new_email@efg.com","mobile":"1234567890"}]}}},{/** convert it back to an arry of [{"k": <k1>, v: <v1>}, {"k": k2, "v": <v2>}]*/"$set":{"attributes":{"$objectToArray":"$attributes"}}},{/** convert "k" --> "key" and "v" --> "value"*/"$set":{"attributes":{"$map":{"input":"$attributes","as":"e","in":{"key":"$$e.k","value":"$$e.v"}}}}},{/** write to the collection*/$merge:{into:"collection",on:"_id",whenMatched:"replace",whenNotMatched:"fail"}}])