gancio-upstream/server/api/models/event.js

35 lines
974 B
JavaScript
Raw Normal View History

2019-06-07 17:02:33 +02:00
'use strict'
2019-06-06 23:54:32 +02:00
module.exports = (sequelize, DataTypes) => {
const event = sequelize.define('event', {
title: DataTypes.STRING,
slug: DataTypes.STRING,
description: DataTypes.TEXT,
multidate: DataTypes.BOOLEAN,
2019-06-07 17:02:33 +02:00
start_datetime: {
type: DataTypes.INTEGER,
index: true
},
end_datetime: {
type: DataTypes.INTEGER,
2019-06-06 23:54:32 +02:00
index: true
},
image_path: DataTypes.STRING,
is_visible: DataTypes.BOOLEAN,
activitypub_id: {
2019-06-25 01:05:38 +02:00
type: DataTypes.STRING(18),
2019-06-06 23:54:32 +02:00
index: true
2019-06-25 01:05:38 +02:00
},
2019-06-07 17:02:33 +02:00
}, {})
event.associate = function (models) {
2019-06-06 23:54:32 +02:00
event.belongsTo(models.place)
event.belongsTo(models.user)
event.belongsToMany(models.tag, { through: 'event_tags' })
event.belongsToMany(models.notification, { through: 'event_notification' })
event.hasMany(models.comment)
2019-06-07 17:02:33 +02:00
// Tag.belongsToMany(Event, { through: 'tagEvent' })
2019-06-06 23:54:32 +02:00
// Event.hasMany(models.Tag)
// associations can be defined here
2019-06-07 17:02:33 +02:00
}
return event
2019-06-09 00:45:50 +02:00
}