1.0.1 • Published 9 years ago

mongoose-parse v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

mongoose-parse

Parse mongoose errors for validation messages

Install

npm install mongoose-parse --save

Usage

var parse = require('mongoose-parse');

new User({ email: 'ponyfoo@ad.ventures' }).save();
new User({ email: 'ponyfoo@ad.ventures' }).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