E11000 duplicate key error index in mongodb mongoose

前端 未结 25 1986
自闭症患者
自闭症患者 2020-11-22 05:49

Following is my user schema in user.js model -

var userSchema = new mongoose.Schema({
    local: {
        name: { type: String },
         


        
25条回答
  •  轮回少年
    2020-11-22 06:37

    I have also faced this issue and I solved it. This error shows that email is already present here. So you just need to remove this line from your Model for email attribute.

    unique: true
    

    This might be possible that even if it won't work. So just need to delete the collection from your MongoDB and restart your server.

提交回复
热议问题