E11000 duplicate key error index in mongodb mongoose

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

Following is my user schema in user.js model -

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


        
25条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 06:28

    I had the same issue. Tried debugging different ways couldn't figure out. I tried dropping the collection and it worked fine after that. Although this is not a good solution if your collection has many documents. But if you are in the early state of development try dropping the collection.

    db.users.drop();
    

提交回复
热议问题