app2-api/modules/events/event_questions.model.js
2019-09-27 16:02:13 +02:00

41 lines
1.1 KiB
JavaScript

'use strict';
module.exports = function (sequelize, DataTypes) {
const EventQuestion = sequelize.define('EventQuestion', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
question: {
type: DataTypes.STRING,
},
anonimous: {
type: DataTypes.INTEGER,
allowNull: true
},
answered: {
type: DataTypes.INTEGER,
allowNull: true
},
discared: {
type: DataTypes.INTEGER,
allowNull: true
},
answer: {
type: DataTypes.TEXT,
},
}, {
tableName: 'events_questions',
freezeTableName: true,
timestamps: true,
});
EventQuestion.associate = function (models) {
EventQuestion.Event = EventQuestion.belongsTo(models.Event, { foreignKey: 'eventId' });
EventQuestion.Speaker = EventQuestion.belongsTo(models.Speaker, { foreignKey: 'speakerId' });
EventQuestion.UserCreate = EventQuestion.belongsTo(models.User, { foreignKey: 'userId' });
};
return EventQuestion;
};