here is my shcema file.
name:{type:String,unique:true,required:true},
email:{type:String,unique:true,required:true},
userName:{type:String,unique:true,required:true},
password:{type:String,unique:true,required:true},
status:{type:String,unique:true,default:true}
},{timestamps:true})
And i'm converting the password in to bcrypt
CodePudding user response:
Just remove the unique property in status. If you declare unique to true all the fields must have the unique value. The value of status will be either true or false. So duplication will occur.
Use this schema
name:{type:String,required:true},
email:{type:String,unique:true,required:true},
userName:{type:String,required:true},
password:{type:String,required:true},
status:{type:String,default:true}
CodePudding user response:
You can add .clone()
after your MongoDB query, this will remove the E11000 duplicate key error