Skip to content

Instantly share code, notes, and snippets.

@qcom
Created January 3, 2014 06:07
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 qcom/8233617 to your computer and use it in GitHub Desktop.
Save qcom/8233617 to your computer and use it in GitHub Desktop.
overwrite mongodb document
DB.prototype.updateTodo = function(id, val, fn) {
this.db.collection('todo').update({ _id : id }, val, function(err) {
if (err) return fn(err);
console.log(arguments);
fn(null);
});
};
/*
console.log output:
{ '0': null,
'1': 0,
'2':
{ updatedExisting: false,
n: 0,
connectionId: 707,
err: null,
ok: 1 } }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment