oprava propojení

This commit is contained in:
Daniel Bulant 2021-10-24 15:32:10 +02:00
parent 37b320d53e
commit 9e693cebdd
2 changed files with 3 additions and 17 deletions

View file

@ -6,26 +6,10 @@ const Student = require("./student");
const GroupStudent = sequelize.define(
"group_student",
{
group: {
type: DataTypes.STRING(16),
allowNull: false,
references: {
model: Group,
key: "id"
}
},
student: {
type: DataTypes.STRING(45),
allowNull: false,
references: {
model: Student,
key: "id"
}
}
},
{
indexes: [{
fields: ["group", "student"],
fields: ["groupId", "studentId"],
type: "UNIQUE"
}]
}

View file

@ -49,7 +49,9 @@ Timetable.belongsTo(Teacher);
Timetable.belongsTo(Room);
Person.hasOne(Student);
Student.belongsTo(Person);
Person.hasOne(Teacher);
Student.belongsTo(Person);
Teacher.belongsTo(Room);