Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{"_id":1,"whoLikes":[1,2],"likesCount":2}]
Query
db.collection.update({_id:1,whoLikes:{$ne:3}},{$push:{whoLikes:3},$inc:{likesCount:1}})
Result