1.0.0 • Published 7 years ago

mongoose-error-parser v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

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