Database
[{"key":1,"counter":100},{"key":2,"counter":500}]
Query
db.collection.update({"key":1},[{"$set":{"counter":{$cond:{if:{$lt:["$counter",500]},then:{$sum:["$counter",1]},else:0}}}}],{"multi":false,"upsert":false})