app2-api/modules/events/events_reservations.model.js
2019-07-10 10:42:03 +02:00

78 lines
2.2 KiB
JavaScript

'use strict';
module.exports = function (sequelize, DataTypes) {
const EventReservation = sequelize.define('EventReservation', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
init_available_date: {
type: DataTypes.DATE,
},
end_available_date: {
type: DataTypes.DATE,
},
gmt: {
type: DataTypes.INTEGER,
defaultValue: 1,
},
state: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'borrador'
},
assistants: {
type: DataTypes.INTEGER,
},
confirmed: {
type: DataTypes.INTEGER,
},
allow_multiple: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
multiple_limit: {
type: DataTypes.INTEGER,
},
description: {
type: DataTypes.STRING,
},
code: {
type: DataTypes.STRING,
allowNull: false,
},
color: {
type: DataTypes.STRING,
allowNull: false,
},
allow_overflow: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
overflow_event_reservationId: {
type: DataTypes.UUID,
foreignKey: true,
},
marketingList: {
type: DataTypes.STRING,
},
}, {
tableName: 'events_reservations',
freezeTableName: true,
timestamps: true,
});
EventReservation.associate = function (models) {
EventReservation.OverflowEventReservation = EventReservation.belongsTo(models.EventReservation, {
as: 'EventToEvent',
foreignKey: 'overflow_event_reservationId' });
EventReservation.Entity = EventReservation.belongsTo(models.Entity, { foreignKey: 'entityId' });
EventReservation.Event = EventReservation.belongsTo(models.Event, { foreignKey: 'eventId' });
EventReservation.UserCreate = EventReservation.belongsTo(models.User, { foreignKey: 'userId' });
};
return EventReservation;
};