inital commit
This commit is contained in:
56
models/ContactPerson.js
Normal file
56
models/ContactPerson.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
|
||||
module.exports = (sequelize) => {
|
||||
const ContactPerson = sequelize.define('ContactPerson', {
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
phone: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true
|
||||
},
|
||||
street: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true
|
||||
},
|
||||
zipcode: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true
|
||||
},
|
||||
city: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true
|
||||
}
|
||||
}, {
|
||||
tableName: 'contact_persons',
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
ContactPerson.associate = function(models) {
|
||||
ContactPerson.belongsToMany(models.Event, {
|
||||
through: models.EventContactPerson,
|
||||
foreignKey: 'contact_person_id',
|
||||
otherKey: 'event_id',
|
||||
as: 'events'
|
||||
});
|
||||
ContactPerson.belongsToMany(models.Position, {
|
||||
through: models.ContactPersonPosition,
|
||||
foreignKey: 'contact_person_id',
|
||||
otherKey: 'position_id',
|
||||
as: 'positions'
|
||||
});
|
||||
ContactPerson.belongsToMany(models.Institution, {
|
||||
through: models.InstitutionContactPerson,
|
||||
foreignKey: 'contact_person_id',
|
||||
otherKey: 'institution_id',
|
||||
as: 'institutions'
|
||||
});
|
||||
};
|
||||
|
||||
return ContactPerson;
|
||||
};
|
||||
Reference in New Issue
Block a user