Fix in association

This commit is contained in:
Torsten Schulz
2024-09-25 18:08:24 +02:00
parent 2b333c43bb
commit fe149f29ba
2 changed files with 3 additions and 5 deletions

View File

@@ -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;

View File

@@ -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,