Answers for "mongoose unique error message"

0

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);
  }
});
Posted by: Guest on November-30-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language