.
This commit is contained in:
parent
854b58187b
commit
90d82741f0
@ -224,9 +224,9 @@ module.exports = function (sequelize, DataTypes) {
|
||||
required: false,
|
||||
});
|
||||
|
||||
Event.Location = Event.hasOne(models.Location, {
|
||||
foreignKey: ['city', 'country'],
|
||||
sourcekey: ['city', 'country'],
|
||||
Event.Location = Event.belongsTo(models.Location, {
|
||||
foreignKey: ['country', 'city'],
|
||||
//sourcekey: ['country', 'city'],
|
||||
as: "location",
|
||||
required: false,
|
||||
});
|
||||
|
||||
@ -22,10 +22,14 @@ module.exports = function (sequelize, DataTypes) {
|
||||
tableName: 'locations',
|
||||
freezeTableName: true,
|
||||
timestamps: true,
|
||||
indexes: [{
|
||||
unique: true,
|
||||
fields: ['country', 'city']
|
||||
}]
|
||||
});
|
||||
|
||||
Location.associate = function (models) {
|
||||
Location.Events = Location.hasMany(models.Event, { as: 'events', foreignKey: ['city', 'country'], sourcekey: ['city', 'country'] });
|
||||
//Location.Events = Location.hasMany(models.Event, { as: 'events', foreignKey: ['country', 'city'] });
|
||||
|
||||
//OJO antes de force comentar
|
||||
// OJO GENERA UN FOREIGN KEY Con eventos y habrá ID de otras entidades que no exitan en la tabla eventos, porque son post o speakers
|
||||
|
||||
Loading…
Reference in New Issue
Block a user