Answers for "unique mongoose not working"

0

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.
Posted by: Guest on October-26-2021

Code answers related to "unique mongoose not working"

Code answers related to "Javascript"

Browse Popular Code Answers by Language