I would like to use findAndModify to atomically increment a field, using Mongoose.
However, the code below throws the error \"TypeError: Object # has no method \'fin
just adding to furf answer that if you use objectId in your query, mongoDB will not be able to find your document. The mongoose layer takes care of converting the Hex string object id you get from the routing params to the proper object id.
to solve this you need to:
var ObjectID = require('mongodb').ObjectID;
var itemId = req.params.itemId;
var objectId = ObjectID.createFromHexString(itemId);
Item.findAndModify({_id: objectId},