Skip to content

Instantly share code, notes, and snippets.

@Ellisande
Created November 16, 2015 18:42
Show Gist options
  • Save Ellisande/eb4344fd5029d86eb93d to your computer and use it in GitHub Desktop.
Save Ellisande/eb4344fd5029d86eb93d to your computer and use it in GitHub Desktop.
Mongoose Required Fields
var paths = _.toArray(models.Recipient.schema.paths);
var requiredFields = paths.filter(function(path){
return path.isRequired;
}).reduce(function(last, path){
last[path.path] = path.path;
return last;
}, {});
console.log(requiredFields);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment