Skip to content

Instantly share code, notes, and snippets.

@cginzel
Created July 5, 2010 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cginzel/464096 to your computer and use it in GitHub Desktop.
Save cginzel/464096 to your computer and use it in GitHub Desktop.
update: function(id, doc, fn){
var self = this;
id = (id instanceof ObjectID || id.toHexString) ? id : ObjectID.createFromHexString(id);
this._collection.update({_id: id}, {$set: doc}, {upsert: false, safe: true}, function(err){
if (err) return self._connection._error(err);
if (fn) return self.findById(id, fn, true);
});
return this;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment