color, weigth, locale, config

This commit is contained in:
lesion
2019-06-26 14:44:21 +02:00
parent b093dae3f3
commit 1087723be8
27 changed files with 188 additions and 86 deletions

View File

@@ -20,15 +20,14 @@ module.exports = (sequelize, DataTypes) => {
index: true
},
}, {})
event.associate = function (models) {
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)
// Tag.belongsToMany(Event, { through: 'tagEvent' })
// Event.hasMany(models.Tag)
// associations can be defined here
}
return event
}

View File

@@ -10,7 +10,7 @@ module.exports = (sequelize, DataTypes) => {
}
}, {})
notification.associate = function (models) {
notification.belongsToMany(models.event, { through: 'event_notification' })
notification.belongsToMany(models.event, { through: models.event_notification })
// associations can be defined here
}
return notification

View File

@@ -1,13 +1,15 @@
'use strict'
module.exports = (sequelize, DataTypes) => {
const place = sequelize.define('place', {
name: DataTypes.STRING,
address: DataTypes.STRING,
weigth: DataTypes.INTEGER
name: {
type: DataTypes.STRING,
unique: true, index: true,
allowNull: false
},
address: DataTypes.STRING
}, {})
place.associate = function (models) {
// associations can be defined here
place.hasMany(models.event)
}

View File

@@ -3,16 +3,16 @@ module.exports = (sequelize, DataTypes) => {
const tag = sequelize.define('tag', {
tag: {
type: DataTypes.STRING,
allowNull: false,
index: true,
primaryKey: true
},
weigth: DataTypes.INTEGER,
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false },
color: DataTypes.STRING
}, {})
tag.associate = function (models) {
tag.belongsToMany(models.event, { through: 'event_tags' })
// associations can be defined here
}
return tag