mongoose unique error message

Solutions on MaxInterview for mongoose unique error message by the best coders in the world

showing results for - "mongoose unique error message"
Simone
10 Sep 2020
1emailVerificationTokenSchema.post('save', function(error, doc, next) {
2  if (error.name === 'MongoError' && error.code === 11000) {
3    next(new Error('email must be unique'));
4  } else {
5    next(error);
6  }
7});
8