app2-api/modules/events/event_questions.model.js
2019-07-05 09:06:29 +02:00

41 lines
1.2 KiB
JavaScript

'use strict';
module.exports = function (sequelize, DataTypes) {
const EventQuestion = sequelize.define('EventQuestion', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
description: {
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;
};