24 lines
567 B
JavaScript
24 lines
567 B
JavaScript
|
"use strict";
|
||
|
|
||
|
const { Model } = require("sequelize");
|
||
|
|
||
|
module.exports = (sequelize, DataTypes) => {
|
||
|
class Group extends Model {
|
||
|
static associate(models) {
|
||
|
Group.belongsTo(models.Semester);
|
||
|
Group.belongsToMany(models.User, {through: "UserGroup"});
|
||
|
Group.belongsToMany(models.Event, {through: "EventGroup"});
|
||
|
}
|
||
|
}
|
||
|
Group.init({
|
||
|
number: {
|
||
|
type: DataTypes.STRING,
|
||
|
allowNull: false
|
||
|
}
|
||
|
}, {
|
||
|
sequelize,
|
||
|
modelName: "Group",
|
||
|
});
|
||
|
return Group;
|
||
|
};
|