Skip to content

Instantly share code, notes, and snippets.

@danared
Created March 27, 2015 18:43
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 danared/be8b2b5f8613b5a17dac to your computer and use it in GitHub Desktop.
Save danared/be8b2b5f8613b5a17dac to your computer and use it in GitHub Desktop.
var updates = { $unset: { steak: true }, $set: { eggs: 0 } };
// Note the `runValidators` option
Breakfast.update({}, updates, { runValidators: true }, function(err) {
console.log(err.errors['steak'].message);
console.log(err.errors['eggs'].message);
/*
* The above error messages output:
* "Path `steak` is required."
* "Path `eggs` (0) is less than minimum allowed value (2)."
*/
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment