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

const MonitoringModel = (DataTypes) => {
  const Monitorings = db.define(
    "monitoring",
    {
      ID_MONITORING: {
        type: DataTypes.UUID,
        primaryKey: true,
        defaultValue: DataTypes.UUIDV4,
        allowNull: false,
        validate: {
          notEmpty: true,
        },
      },
      ID_STUDENT_LEARNING: {
        type: DataTypes.UUID,
        allowNull: false,
        validate: {
          notEmpty: true,
        },
        references: {
          model: "student_learning",
          key: "ID_STUDENT_LEARNING",
        },
      },
      ID_CLASS: {
        type: DataTypes.UUID,
        allowNull: true,
        references: {
          model: "class",
          key: "ID_CLASS",
        },
      },
      ID_GURU: {
        type: DataTypes.UUID,
        allowNull: true,
        references: {
          model: "teacher",
          key: "ID_GURU",
        },
      },
      FEEDBACK_GURU: {
        type: DataTypes.TEXT,
        allowNull: true,
      },
      TIME_MONITORING: {
        type: DataTypes.DATE,
        allowNull: true,
        defaultValue: DataTypes.NOW,
      },
    },
    {
      timestamps: false,
      tableName: "monitoring", 
    }
  );
  return Monitorings;
};

export default MonitoringModel;
