inital commit

This commit is contained in:
Torsten Schulz
2024-06-15 23:01:46 +02:00
parent 1b7fefe381
commit 61653ff407
105 changed files with 7805 additions and 524 deletions

52
models/Institution.js Normal file
View File

@@ -0,0 +1,52 @@
const { DataTypes } = require('sequelize');
module.exports = (sequelize) => {
const Institution = sequelize.define('Institution', {
name: {
type: DataTypes.STRING,
allowNull: false
},
street: {
type: DataTypes.STRING,
allowNull: true
},
zipcode: {
type: DataTypes.STRING,
allowNull: true
},
city: {
type: DataTypes.STRING,
allowNull: true
},
phone: {
type: DataTypes.STRING,
allowNull: true
},
fax: {
type: DataTypes.STRING,
allowNull: true
},
email: {
type: DataTypes.STRING,
allowNull: true
}
}, {
tableName: 'institutions',
timestamps: false
});
Institution.associate = function(models) {
Institution.belongsToMany(models.ContactPerson, {
through: models.InstitutionContactPerson,
foreignKey: 'institution_id',
otherKey: 'contact_person_id',
as: 'contactPersons'
});
Institution.hasMany(models.Event, {
foreignKey: 'institution_id',
as: 'events'
});
};
return Institution;
};