Model.events

Type:
  • «property»

Event emitter that reports any errors that occurred. Useful for global error handling.

Example:

  1. MyModel.events.on('error', err => console.log(err.message));
  2. // Prints a 'CastError' because of the above handler
  3. await MyModel.findOne({ _id: 'notanid' }).catch(noop);