Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{_id:1,rep:100,published:true},{_id:2,rep:100,published:false}]
Query
db.collection.update({"_id":2},[{$set:{"rep":{$cond:{if:{$eq:["$published",false]},then:{$add:["$rep",1]},else:{$add:["$rep",2]}}}}}])
Result