mongoose-error

1.0.1 • Public • Published

mongoose-error

NPM version Linux Build Status

Small Node.js utility to normalize mongoose errors.

Installation

$ npm install mongoose-error --save

Usage

mongoose-error normalize the error message to include the first validation error, and can also catch mongo duplicate key.

const mongooseError = require('mongoose-error');
 
user.save()
.then(
    () => {
        console.log('saved!');
    },
    (err) => {
        throw mongooseError(err, {
            DuplicateKey: 'An user with this username already exist'
        });
    }
);

Readme

Keywords

Package Sidebar

Install

npm i mongoose-error

Weekly Downloads

2

Version

1.0.1

License

Apache-2.0

Last publish

Collaborators

  • taranvohra
  • gitbook-bot
  • samypesse
  • jpreynat
  • emmerich