Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose unique error message

emailVerificationTokenSchema.post('save', function(error, doc, next) {
  if (error.name === 'MongoError' && error.code === 11000) {
    next(new Error('email must be unique'));
  } else {
    next(error);
  }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mongoose #unique #error #message
ADD COMMENT
Topic
Name
2+6 =