mongoose-error-parser
v1.0.0
Published
Easily parse mongoose errors.
Downloads
22
Readme
mongoose-error-parser
Easily parse mongoose errors.
Install
npm i mongoose-error-parser
Basic usage
// ...
const parse = require("mongoose-error-parser");
const user = new User({
username: "John",
password: "coffee123"
});
user.save(function(err) {
console.log(parse(err)); // If any errors logs parsed
});
Output
Function returns object with following properties
fields
Fields in which the error occurred
errors
Array of errors