I'm basically trying to just hash a password using bcrypt using async/await but nothing is working... next() is not working and it is not saving the data into the database and even not hashing the password
const bcrypt = require("bcryptjs")
userSchema.pre('save', async function (next) {
try {
const salt = await bcrypt.genSalt(10)
console.log(this.email, this.password);
const hashedPassword = await bcrypt.hash(this.password, salt)
//above line making problem to me... I don't know but below the above line code is not working... plz help me to figure out the mistake
this.password = hashedPassword
console.log(`the hashed password is ${this.password}`);
next()
} catch (error) {
next(error)
}
})