0
架構中,我有貓鼬架構驗證
email: {
type: String,
required: [true, "Email is required"],
unique: true
}
for validation with "unique" i am create
schema.path('email').validate(function(v){
mongoose.models['User'].findOne({email: this.email}, function(err, user){
if(err){
throw err;
}else{
if(user){
this.invalidate("email", "Email exists!");
}
}
});
}, null);
,但我有一個錯誤: this.invalidate不是一個函數。誰能幫我?
感謝,它幫助我)! – MrGabriel