text: const { Model, DataTypes } = require('sequelize');
  const bcrypt = require('bcrypt');
  const sequelize = require('../config/connection');
  
  class User extends Model {
    checkPassword(loginPw) {
      console.log(loginPw)
      console.log(this.password);
      return bcrypt.compareSync(loginPw, this.password);
    }
    checkIsValid() {
      return this.is_valid;
    }
  }
  
  User.init(
    {
      id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
      },
      first_name: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      last_name: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      username: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      email: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
        validate: {
          isEmail: true,
        },
      },
      password: {
        type: DataTypes.STRING,
        allowNull: false,
        validate: {
          len: [8],
        },
      },
  
      is_artist: {
        type: DataTypes.STRING,
        allowNull: false,
      },
  
      unique_string: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      is_valid: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
      },
    },
    {
      hooks: {
        beforeCreate: async (newUserData) => {
          newUserData.password = await bcrypt.hash(newUserData.password, 10);
          return newUserData;
        },
      },
      sequelize,
      timestamps: false,
      freezeTableName: true,
      underscored: true,
      modelName: "User",
    }
  );
  
  module.exports = User;