It seems to me that you are talking about two different things. Idempotence would mean that you can send several times the increase
instruction but the counter would only be increased once. Atomicity does not make sense for a single operation (it makes sense for more than one, for example, increase the counter AND the date of increase atomically; either both get modified, or none does).
MongoDB supports atomic operations at the "document" level (which I'm not sure you need), but obviously an increment operator is not idempotent (by definition! How would you increase your counter otherwise?).
Can you clarify your question?
Also, you cannot have an "eventually consistent" database where all the nodes will have the same value of a given key at every time. That's why it is "eventually consistent", because it cannot guarantee that they are the same "right now".
As for an answer, if you want to use MongoDB for maintaining an increment operator, use the following pattern (from their website, example of the [$inc operator][1]
):
db.collection.update( { age: 20 }, { $inc: { age: 1 } } );
db.collection.update( { name: "John" }, { $inc: { age: 1 } } );
In your case, it would be db.collection.update({$inc:{mycounter:1}});