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

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -