47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
|
|
import db from "../database/db.js";
|
||
|
|
|
||
|
|
const TopicModel = (DataTypes) => {
|
||
|
|
const Topics = db.define(
|
||
|
|
"m_topics",
|
||
|
|
{
|
||
|
|
id: {
|
||
|
|
type: DataTypes.INTEGER,
|
||
|
|
primaryKey: true,
|
||
|
|
autoIncrement: true,
|
||
|
|
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
|
||
|
|
},
|
||
|
|
},
|
||
|
|
title: {
|
||
|
|
type: DataTypes.STRING(255),
|
||
|
|
allowNull: false,
|
||
|
|
validate: {
|
||
|
|
notEmpty: true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
ts_entri: {
|
||
|
|
type: DataTypes.DATE,
|
||
|
|
allowNull: true,
|
||
|
|
defaultValue: DataTypes.NOW,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
timestamps: false, // Disable Sequelize's automatic timestamp fields (createdAt, updatedAt)
|
||
|
|
tableName: "m_topics", // Ensure the table name matches the actual table name
|
||
|
|
}
|
||
|
|
);
|
||
|
|
return Topics;
|
||
|
|
};
|
||
|
|
|
||
|
|
export default TopicModel;
|