Database
[{"id":1,"comments":[{"id":1,"text":"Comment 1","likedBy":["Tomato","Potato"],},{"id":2,"text":"Comment 2","likedBy":["Carrot"],},],},]
Query
db.collection.update({"id":1,"comments.id":1},[{"$set":{"comments":{"$map":{"input":"$comments","in":{"$cond":[{"$eq":["$$this.id",1]},{"$mergeObjects":["$$this",{"likedBy":{"$cond":[{"$in":["Potato","$$this.likedBy"]},{"$setDifference":["$$this.likedBy",["Potato"]]},{"$concatArrays":["$$this.likedBy",["Potato"]]}]}}]},"$$this"]}}}}}])