inital commit
This commit is contained in:
64
models/event.js
Normal file
64
models/event.js
Normal file
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user