4
나는 이와 같은 정보를 업데이트하고 싶은 사용자 스키마가 있습니다.몽구스 모델 (node.js)의 한 필드 업데이트
User.findOne({_id: idd}, function(err, usr){
usr.info = "some new info";
usr.save(function(err) {
});
});
그러나 모델이 나는 그것이 allready hased 암호를 취 저장하려고 다시 해시 때 이제 암호
UserSchema.pre('save', function(next) {
if (this.password && this.password.length > 6) {
this.salt = new Buffer(crypto.randomBytes(16).toString('base64'), 'base64');
this.password = this.hashPassword(this.password);
}
next();
});
을 해시 저장에 후크를 가지고, 어떤 아이디어는 어떻게이 문제를 방지하려면?
감사합니다. 해결책이있는 것 같습니다. :) – user1930848