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

const StudentModel = (DataTypes) => {
  const Students = db.define(
    "student",
    {
      ID_SISWA: {
        type: DataTypes.UUID,
        primaryKey: true,
        defaultValue: DataTypes.UUIDV4,
        allowNull: false,
        validate: {
          notEmpty: true,
        },
      },
      ID_CLASS: {
        type: DataTypes.UUID,
        allowNull: true,
        references: {
          model: "class",
          key: "ID_CLASS",
        },
      },
      ID: {
        type: DataTypes.UUID,
        allowNull: false,
        validate: {
          notEmpty: true,
        },
        references: {
          model: "users",
          key: "ID",
        },
      },
      NISN: {
        type: DataTypes.BIGINT(11),
        allowNull: false,
        unique: true,
        validate: {
          notEmpty: true,
        },
      },
    },
    {
      timestamps: false,
      tableName: "student",
    }
  );
  return Students;
};

export default StudentModel;
