text: import mongoose from "mongoose";
  import bcrypt from "bcryptjs";
  
  const UserSchema = new mongoose.Schema(
      {
          firstName: String,
          lastName: String,
          username: String,
          email: String,
          password: String,
          // isAdmin: Boolean,
      },
      {
          timestamps: true,
      }
  );
  
  UserSchema.methods.matchPassword = async function(password) {
      return await bcrypt.compare(password, this.password);
  }
  
  UserSchema.pre('save', async function(next) {
      if (!this.isModified("password")) {
          next();
      }
  
      const salt = await bcrypt.genSalt(10);
      this.password = await bcrypt.hash(this.password, salt);
  
  });
  
  const User = mongoose.model('User', UserSchema);
  
  export default User;