ssps-bot/utils/models/group_student.js
Daniel Bulant 0f0e5debef test
2021-10-23 16:19:56 +02:00

36 lines
No EOL
893 B
JavaScript

const { Sequelize, Op, Model, DataTypes } = require("sequelize");
const sequelize = require("../sequelize");
const Group = require("./group");
const Student = require("./student");
const GroupStudent = sequelize.define(
"group_students",
{
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"],
type: "UNIQUE"
}]
}
);
EventStudent.belongsTo(Student, { as: "student" });
EventStudent.belongsTo(Group, { as: "group" });
module.exports = GroupStudent;