.
This commit is contained in:
parent
854b58187b
commit
90d82741f0
@ -224,9 +224,9 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
required: false,
|
required: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
Event.Location = Event.hasOne(models.Location, {
|
Event.Location = Event.belongsTo(models.Location, {
|
||||||
foreignKey: ['city', 'country'],
|
foreignKey: ['country', 'city'],
|
||||||
sourcekey: ['city', 'country'],
|
//sourcekey: ['country', 'city'],
|
||||||
as: "location",
|
as: "location",
|
||||||
required: false,
|
required: false,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,10 +22,14 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
tableName: 'locations',
|
tableName: 'locations',
|
||||||
freezeTableName: true,
|
freezeTableName: true,
|
||||||
timestamps: true,
|
timestamps: true,
|
||||||
|
indexes: [{
|
||||||
|
unique: true,
|
||||||
|
fields: ['country', 'city']
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
Location.associate = function (models) {
|
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 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
|
// 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