text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const bcrypt = require("bcrypt");
  const mongoose = require("mongoose");
  const userSchema = new mongoose.Schema({
      firstName: { type: String, required: true },
      lastName: { type: String, required: true },
      email: { type: String, required: true, index: { unique: true } },
      password: { type: String, required: true },
      tagId: String,
  });
  userSchema.pre("save", function save(next) {
      const user = this;
      if (!user.isModified("password")) {
          return next();
      }
      bcrypt.genSalt(10, (err, salt) => {
          if (err) {
              return next(err);
          }
          bcrypt.hash(user.password, salt, (err, hash) => {
              if (err) {
                  return next(err);
              }
              user.password = hash;
              next();
          });
      });
  });
  userSchema.methods.comparePassword = function (candidatePassword, cb) {
      bcrypt.compare(candidatePassword, this.password, (err, isMatch) => {
          cb(err, isMatch);
      });
  };
  exports.User = mongoose.model("User", userSchema);
  