Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading aliases in "Multiple associations involving the same models" documentation #87

Open
1 task done
kirill-ianchuk opened this issue Apr 14, 2022 · 1 comment · May be fixed by #280
Open
1 task done

Comments

@kirill-ianchuk
Copy link

kirill-ianchuk commented Apr 14, 2022

Issue Creation Checklist

Issue Description

What was unclear/insufficient/not covered in the documentation

I suspect that Chapter Multiple associations involving the same models contains misleading examples of association aliases:

Team.hasOne(Game, { as: 'HomeTeam', foreignKey: 'homeTeamId' });
Team.hasOne(Game, { as: 'AwayTeam', foreignKey: 'awayTeamId' });
Game.belongsTo(Team);

If I define HomeTeam and AwayTeam aliases, then, for instance, to fetch the team's home game using lazy loading I need to call team.getHomeTeam(). This doesn't make sense to me.

If possible: Provide some suggestion on how we can enhance the docs

To change the aliases to HomeGame and AwayGame:

Team.hasOne(Game, { as: 'HomeGame', foreignKey: 'homeTeamId' });
Team.hasOne(Game, { as: 'AwayGame', foreignKey: 'awayTeamId' });
Game.belongsTo(Team);
@WikiRik WikiRik transferred this issue from sequelize/sequelize Apr 14, 2022
@WikiRik
Copy link
Member

WikiRik commented Apr 14, 2022

I transferred this to the website repo, where we store the documentation files. Thanks for the suggestion, we'll take a look at it soon!

fzn0x added a commit that referenced this issue Oct 2, 2022
@fzn0x fzn0x linked a pull request Oct 2, 2022 that will close this issue
@ephys ephys removed the type: docs label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants