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
2
Answers
You can add
.clone()
after your MongoDB query, this will remove the E11000 duplicate key errorJust remove the unique property in status. If you declare
unique
totrue
all the fields must have theunique
value. The value of status will be eithertrue
orfalse
. So duplication will occur.Use this schema: