I'm wondering how do I mutate or change the request body of the End-User before finally update and save the document in mongoose? like this 'save' event of mongoose middleware
schema.pre('save', async function () {
const salt = await bcrypt.genSalt();
this.password = await bcrypt.hash(this.password, salt);
});
I just want it, to do like this so
schema.pre('updateOne', async function () {
const salt = await bcrypt.genSalt();
this.password = await bcrypt.hash(this.password, salt);
});