Skip to content

Instantly share code, notes, and snippets.

@astrotars
Created January 15, 2013 22:35
Show Gist options
  • Select an option

  • Save astrotars/4542814 to your computer and use it in GitHub Desktop.

Select an option

Save astrotars/4542814 to your computer and use it in GitHub Desktop.
Update w/ Mongoose [casts values to appropriate types but does not run validators, middleware, defaults, or setters]
// assign update client to var
var updateclient = req.body;
remove default to avoid mongo errors (like Mod on _id not allowed)
delete updateclient._id;
Client.update({_id: req.params.client_id}, updateclient, {}, function(err, client) {
if (err)
return next(new restify.InternalError(err));
res.send(req.body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment