coen-hyde/Shanty-Mongo — Issue #61: How to implement findAndModify operation with Shanty Mongo?
Author: valeeum
Created: 2012-01-15 03:52:45+00:00
State: open

I'm trying to recreate the following shell function using the Shanty Mongo library. Can anybody help point me in the right direction?

function counter(name) {
var ret = db.counters.findAndModify({query:{_id:name}, update:{$inc : {next:1}}, "new":true, upsert:true});
return ret.next;
}

I guess my real question is how can I execute a "findAndModify" operation?