text: const { Model, DataTypes } = require('sequelize');
  const bcrypt = require('bcrypt');
  const sequelize = require('../config/connection.js');
  
  class User extends Model {
    checkPassword(password) {
        return bcrypt.compareSync(password, this.password);
    }
  }
  
  User.init(
    {
      id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
      },
      user_name: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      email: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      password: {
        type: DataTypes.STRING,
        allowNull:false
      }
    },
    {
      hooks: {
          async beforeCreate(dbUserData) {
            dbUserData.password = await bcrypt.hash(dbUserData.password, 10);
            return dbUserData;
          },
      },
      sequelize,
      timestamps: false,
      freezeTableName: true,
      underscored: true,
      modelName: 'user',
    }
  );
  
  module.exports = User;