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
Post a Comment