Last active
August 29, 2015 13:59
-
-
Save danfinlay/10938369 to your computer and use it in GitHub Desktop.
A tricky problem involved named through associations in Geddy's Model. This current arrangement throws the error `Error: The property "adminTeamTeamId" is not a valid property on the TeamAdmin model.`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Team = function () { | |
| this.hasMany('TeamUsers'); | |
| this.hasMany('Users', {through: 'TeamUsers'}); | |
| this.hasMany('TeamAdmins'); | |
| this.hasMany('Admins', { | |
| through: 'TeamAdmins', | |
| model: 'Users' | |
| }); | |
| } | |
| exports.Team = Team; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var TeamAdmin = function () { | |
| this.belongsTo('AdminTeam',{model:'Team'}); | |
| this.belongsTo('User'); | |
| }; | |
| exports.TeamAdmin = TeamAdmin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var TeamUser = function () { | |
| this.belongsTo('Team'); | |
| this.belongsTo('User'); | |
| }; | |
| exports.TeamUser = TeamUser; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var User = function () { | |
| this.hasMany('TeamUsers'); | |
| this.hasMany('Teams', {through: 'TeamUsers'}); | |
| this.hasMany('TeamAdmins'); | |
| this.hasMany('AdminTeams', {through: 'TeamAdmins', model:'Teams'}); | |
| } | |
| exports.User = User; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment