backend_adaptive_learning/models/levelModel.js

104 lines
2.3 KiB
JavaScript
Raw Normal View History

import db from "../database/db.js";
const LevelModel = (DataTypes) => {
const Levels = db.define(
"m_levels",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
validate: {
notEmpty: true,
},
},
title: {
type: DataTypes.STRING(100),
allowNull: false,
validate: {
notEmpty: true,
},
},
subject_id: {
type: DataTypes.INTEGER,
allowNull: false,
validate: {
notEmpty: true,
},
references: {
model: 'm_subjects', // Name of the referenced table
key: 'id', // Key in the referenced table
},
},
topic_id: {
type: DataTypes.INTEGER,
allowNull: false,
validate: {
notEmpty: true,
},
references: {
model: 'm_topics', // Name of the referenced table
key: 'id', // Key in the referenced table
},
},
is_pretest: {
type: DataTypes.TINYINT(1),
allowNull: true,
defaultValue: 0,
validate: {
min: 0,
max: 1,
},
},
content: {
type: DataTypes.STRING(200),
allowNull: true,
},
video: {
type: DataTypes.STRING(200),
allowNull: true,
},
audio: {
type: DataTypes.STRING(200),
allowNull: true,
},
image: {
type: DataTypes.STRING(200),
allowNull: true,
},
youtube: {
type: DataTypes.STRING(200),
allowNull: true,
},
route1: {
type: DataTypes.INTEGER,
allowNull: false,
},
route2: {
type: DataTypes.INTEGER,
allowNull: false,
},
route3: {
type: DataTypes.INTEGER,
allowNull: false,
},
route4: {
type: DataTypes.INTEGER,
allowNull: false,
},
ts_entri: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: DataTypes.NOW,
},
},
{
timestamps: false, // Disable Sequelize's automatic timestamp fields (createdAt, updatedAt)
tableName: "m_levels", // Ensure the table name matches the actual table name
}
);
return Levels;
};
export default LevelModel;