Mongodb – How to handle mongoose errors globaly
As for now, I'm using mongoose middleware to handle Mongoose specific errors (validation, cast, ....). I'm using the following code in all of my schemas: schema.post('save', handleValidationError); schema.post('findOneAndUpdate', handleValidationError); schema.post(['findOne', 'deleteOne'], handleCastError); Is there anyway to make this global in…