import db from "../../database/db.js";

const UserModel = (DataTypes) => {
  const Users = db.define(
    "users",
    {
      ID: {
        type: DataTypes.UUID,
        primaryKey: true,
        defaultValue: DataTypes.UUIDV4,
        allowNull: false,
        validate: {
          notEmpty: true,
        },
      },
      NAME_USERS: {
        type: DataTypes.STRING(100),
        allowNull: false,
        validate: {
          notEmpty: true,
        },
      },
      EMAIL: {
        type: DataTypes.STRING(100),
        allowNull: false,
        unique: true,
        validate: {
          notEmpty: true,
          isEmail: true,
        },
      },
      PASSWORD: {
        type: DataTypes.STRING(100),
        allowNull: false,
      },
      ROLE: {
        type: DataTypes.STRING(100),
        allowNull: true,
      },
      PICTURE: {
        type: DataTypes.STRING(1024),
        allowNull: true,
      },
      IS_VALIDATED: {
        type: DataTypes.TINYINT(1),
        allowNull: true,
        defaultValue: 0,
      },
      REFRESH_TOKEN: {
        type: DataTypes.STRING(256),
        allowNull: true,
      },
      TIME_USERS: {
        type: DataTypes.DATE,
        allowNull: true,
        defaultValue: DataTypes.NOW,
      },
    },
    {
      timestamps: false,
      tableName: "users",
    }
  );
  return Users;
};

export default UserModel;
