unique mongoose not working
//Add unique: true to the attributes.
const schema = new mongoose.Schema(
{
email: {
type: String,
unique: true,
required: true,
}
}
);
module.exports = mongoose.model("mail", schema);
//Drop the collection - for example mail (look at the line 13 at end)
//Delete all records in collection to remove duplicates for the unique column
//Restart the Node.js server, that uses mongoose library.