I have 2 unique keys in my userSchema:
email: {
type: String,
required: true,
unique: true
},
username: {
type: String,
required: true,
unique: true
}
You can't add neither username nor email which already exist in the database. How can I tell user which one exactly already exists in the database, because there is only one error code?
if (err.code == 11000)
return res.status(422).send(['Duplicate email adrress found.']);