65 lines
1.3 KiB
JavaScript
65 lines
1.3 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
|
|
module.exports = (sequelize) => {
|
|
const Event = sequelize.define('Event', {
|
|
uniqueId: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true
|
|
},
|
|
eventTypeId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true
|
|
},
|
|
eventPlaceId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true
|
|
},
|
|
date: {
|
|
type: DataTypes.DATE,
|
|
allowNull: true
|
|
},
|
|
time: {
|
|
type: DataTypes.TIME,
|
|
allowNull: true
|
|
},
|
|
endTime: {
|
|
type: DataTypes.TIME,
|
|
allowNull: true
|
|
},
|
|
dayOfWeek: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true
|
|
}
|
|
}, {
|
|
tableName: 'events',
|
|
timestamps: true
|
|
});
|
|
|
|
Event.associate = function(models) {
|
|
Event.belongsTo(models.Institution, {
|
|
foreignKey: 'institution_id',
|
|
as: 'institution'
|
|
});
|
|
Event.belongsTo(models.EventPlace, {
|
|
foreignKey: 'event_place_id',
|
|
as: 'eventPlace'
|
|
});
|
|
Event.belongsToMany(models.ContactPerson, {
|
|
through: 'EventContactPerson',
|
|
foreignKey: 'event_id',
|
|
otherKey: 'contact_person_id',
|
|
as: 'contactPersons'
|
|
});
|
|
};
|
|
|
|
return Event;
|
|
};
|