mongoose-parse
Parse
mongoose
errors for validation messages
Install
npm install mongoose-parse --save
Usage
var parse = require('mongoose-parse');
new User({ email: '[email protected]' }).save();
new User({ email: '[email protected]' }).save(function saved (err) {
console.log(parse(err));
});
Parsing the error with mongoose-parse
will yield the following.
{
"code": 11000,
"path": "email"
}
If a duplicate key error isn't detected, the original error object will be returned.
License
MIT