backend_adaptive_learning/models/usersModels/teacherModel.js

51 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-09-13 13:03:35 +00:00
import db from "../../database/db.js";
const TeacherModel = (DataTypes) => {
const Teachers = db.define(
"teacher",
{
ID_GURU: {
type: DataTypes.UUID,
primaryKey: true,
defaultValue: DataTypes.UUIDV4,
allowNull: false,
validate: {
notEmpty: true,
},
},
ID: {
type: DataTypes.UUID,
allowNull: false,
validate: {
notEmpty: true,
},
references: {
model: "users",
key: "ID",
},
},
NIP: {
2024-10-14 01:23:37 +00:00
type: DataTypes.BIGINT(11),
2024-09-13 13:03:35 +00:00
allowNull: false,
unique: true,
validate: {
notEmpty: true,
is16Digits(value) {
const stringValue = value.toString();
2024-12-19 03:31:46 +00:00
if (stringValue.length !== 18) {
throw new Error("NIP must be exactly 18 digits long");
}
},
2024-09-13 13:03:35 +00:00
},
},
},
{
timestamps: false,
tableName: "teacher",
}
);
return Teachers;
};
export default TeacherModel;