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,