Database

[{"key":1}]

Query

db.collection.update({key:2},{"$inc":{"counter":1}},{upsert:true,new:true})

Result