mongoose-errors-helper

1.0.0 • Public • Published

Mongoose Helper

A utility module to deal with Mongoose in web APIs development. Currently supports validation errors checking and extraction. Might be extended for future needs.

Usage

var mongooseHelper = require('mongoose-helper');

var models = require('./models');

var entity = new models.Entity({ /* Some props */ });
entity.save().then(function(savedEntity) {
    // Do something
}).catch(function(err) {
    if (mongooseHelper.isValidationError(err)) {
		var errors = mongooseHelper.getValidationErrors(err);
		// Do something with the errors extracted
	}
});

Notes

The errors are extracted as an array of strings.

Readme

Keywords

none

Package Sidebar

Install

npm i mongoose-errors-helper

Weekly Downloads

0

Version

1.0.0

License

LGPL-3.0

Unpacked Size

1.34 kB

Total Files

3

Last publish

Collaborators

  • uwburn