text: const { Schema, model } = require('mongoose');
  const bcrypt = require('bcryptjs');
  
  const userSchema = new Schema({
      name: {
          type: String,
          required: true
      },
      userName: {
          type: String,
          required: true,
          unique: true,
          trim: true
      },
      email: {
          type: String,
          required: true,
          unique: true,
          trim: true
      },
      password: {
          type: String,
          required: true,
          trim: true
      },
      roles: [{
          ref: "Role",
          type: Schema.Types.ObjectId
      }]
  },
      {
          timestamps: true,
          versionKey: false,
      }
  );
  
  userSchema.statics.encryptPassword = async (password) => {
      const salt = await bcrypt.genSalt(12)
      return await bcrypt.hash(password, salt)
  };
  
  userSchema.statics.comparePassword = async (password, receivedPassword) => {
      return await bcrypt.compare(password, receivedPassword)
  };
  
  module.exports = model('User', userSchema);