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

43 lines
1.3 KiB
JavaScript

'use strict';
module.exports = function (sequelize, DataTypes) {
const EventInscription = sequelize.define('EventInscription', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
date: {
type: DataTypes.DATE,
},
code_ticket: {
type: DataTypes.INTEGER,
},
type: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'regular' //grupal, invitacion-regular, invitation-grupal
},
source: {
type: DataTypes.STRING, //app, web
},
marketing_memberId: {
type: DataTypes.STRING,
},
validated: {
type: DataTypes.DATE,
},
}, {
tableName: 'events_inscriptions',
freezeTableName: true,
timestamps: true,
});
EventInscription.associate = function (models) {
EventInscription.Event = EventInscription.belongsTo(models.Event, { foreignKey: 'eventId' });
EventInscription.User = EventInscription.belongsTo(models.User, { foreignKey: 'userId' });
EventInscription.UserValidate = EventInscription.belongsTo(models.User, { foreignKey: 'validateUserId' });
};
return EventInscription;
};