Created
August 4, 2012 10:02
-
-
Save lancejpollard/3256493 to your computer and use it in GitHub Desktop.
Tower hasMany through example
This file contains 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
class App.Group extends Tower.Model | |
@field 'title', type: 'String' | |
@hasMany 'memberships' | |
@hasMany 'users', through: 'memberships' | |
@timestamps() |
This file contains 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
class App.Membership extends Tower.Model | |
@belongsTo 'group' | |
@belongsTo 'user' | |
@timestamps() |
This file contains 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
class App.User extends Tower.Model | |
@field 'email', type: 'String' | |
@hasMany 'memberships' | |
@hasMany 'groups', through: 'memberships' | |
@timestamps() |
This file contains 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 = App.User.create() | |
user.get('groups').create(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment