From fe149f29ba85cd79be9838e49082573efd550948 Mon Sep 17 00:00:00 2001 From: Torsten Schulz Date: Wed, 25 Sep 2024 18:08:24 +0200 Subject: [PATCH] Fix in association --- backend/models/UserClub.js | 3 --- backend/models/index.js | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/models/UserClub.js b/backend/models/UserClub.js index 2bef85d..e4f5898 100644 --- a/backend/models/UserClub.js +++ b/backend/models/UserClub.js @@ -28,7 +28,4 @@ const UserClub = sequelize.define('UserClub', { timestamps: true }); -User.belongsToMany(Club, { through: UserClub, foreignKey: 'userId' }); -Club.belongsToMany(User, { through: UserClub, foreignKey: 'clubId' }); - export default UserClub; diff --git a/backend/models/index.js b/backend/models/index.js index eaf5346..2fe5a76 100644 --- a/backend/models/index.js +++ b/backend/models/index.js @@ -85,8 +85,9 @@ Season.hasMany(Match, { foreignKey: 'seasonId', as: 'matches' }); Match.belongsTo(Location, { foreignKey: 'locationId', as: 'location' }); Location.hasMany(Match, { foreignKey: 'locationId', as: 'matches' }); -User.belongsTo(UserClub, { foreignKey: 'userId', as: 'clubUser' }); -UserClub.hasMany(User, { foreignKey: 'userId', as: 'userClub' }); +User.belongsToMany(Club, { through: UserClub, foreignKey: 'userId', otherKey: 'clubId' }); +Club.belongsToMany(User, { through: UserClub, foreignKey: 'clubId', otherKey: 'userId' }); + export { User, Log,