✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
MongoDB
У схемі користувача є pre-save хук для хешування пароля:
userSchema.pre('save', async function() {
if (this.isModified('password')) {
this.password = await bcrypt.hash(this.password, 10);
}
});
Чому перевірка isModified('password') критично важлива?