const mongoose = require('mongoose') const bcrypt = require('bcrypt') const UserSchema = mongoose.Schema({ username: { type: String }, email: { type: String, required: true }, password: { type: String, required: true }, profilePicUrl: { type: String }, isActive: { type: Boolean, default: true }, isVerified: { type: Boolean, default: false }, updated_at: { type: Date, default: Date.now }, created_at: { type: Date, default: Date.now } }) UserSchema.pre('save', async function (next) { if (!this.isModified('password')) { next() } const salt = bcrypt.genSalt(10); this.password = await bcrypt.hash(this.password, salt); }) module.exports = mongoose.model('User',UserSchema)