Mongoose save() using native promise - how to catch errors -


i trying catch errors thrown mongoose using mongoose's native promises. don't know error object mongoose.

i errors thrown in .then()s , caught in .catch() if possible.

var contact = new aircraftcontactmodel(postvars.contact); contact.save().then(function(){     var aircraft = new aircraftmodel(postvars.aircraft);     return aircraft.save(); }) .then(function(){     console.log('aircraft saved') }).catch(function(){     // want handle errors here }); 

trying not use library, .save() returns promise natively.

you can extend promise functionality on mongoose bluebird

promise = require('bluebird'); mongoose.promise = promise; 

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -