From 03ab768c61c11fdf7db7d00722fb3548edc728aa Mon Sep 17 00:00:00 2001 From: Torsten Schulz Date: Wed, 25 Sep 2024 17:52:53 +0200 Subject: [PATCH] Associations fix --- backend/models/index.js | 2 ++ backend/services/clubService.js | 1 + 2 files changed, 3 insertions(+) diff --git a/backend/models/index.js b/backend/models/index.js index 3d5c610..e4363d0 100644 --- a/backend/models/index.js +++ b/backend/models/index.js @@ -85,6 +85,8 @@ 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: 'userClub', as: 'clubUser' }); +UserClub.hasMany(User, { foreignKey: 'userClub', as: 'userClub' }); export { User, Log, diff --git a/backend/services/clubService.js b/backend/services/clubService.js index ca1ff46..a6ff645 100644 --- a/backend/services/clubService.js +++ b/backend/services/clubService.js @@ -104,6 +104,7 @@ class ClubService { include: [ { model: User, + as: 'clubUser', attributes: ['id', 'firstName', 'lastName', 'email'] } ]