1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
letu/models/semester.js

29 lines
703 B
JavaScript
Raw Normal View History

2020-11-22 16:48:06 +01:00
"use strict";
const { Model } = require("sequelize");
module.exports = (sequelize, DataTypes) => {
class Semester extends Model {
static associate(models) {
2021-01-20 17:14:33 +01:00
Semester.hasMany(models.Group, {foreignKey: {allowNull: false}});
2020-11-22 16:48:06 +01:00
Semester.belongsToMany(models.Event, {through: "EventSemester"});
}
}
Semester.init({
year: {
type: DataTypes.INTEGER,
allowNull: false,
unique: "semester"
},
name : {
type: DataTypes.STRING,
allowNull: false,
unique: "semester"
}
}, {
sequelize,
modelName: "Semester",
});
return Semester;
};