Skip to content

Instantly share code, notes, and snippets.

View Asraf2asif's full-sized avatar
🔥
Job haunting on Fiverr and Upwork

Asif Asraf2asif

🔥
Job haunting on Fiverr and Upwork
View GitHub Profile
UserSchema.pre("insertMany", async function (next, docs) {
if (Array.isArray(docs) && docs.length) {
const hashedUsers = docs.map(async (user) => {
return await new Promise((resolve, reject) => {
bcrypt.genSalt(10).then((salt) => {
let password = user.password.toString()
bcrypt.hash(password, salt).then(hash => {
user.password = hash
resolve(user)
}).catch(e => {