here is my complete code
var express = require(\'express\'), app = express(), mongoose = require(\'mongoose\'), bodyParser = require(\'body-parse
Do like this:
UserSchema.pre('save', async function (next) { const hash = await bcrypt.hash(this.password, 10); this.password = hash; next() })