Skip to content

Instantly share code, notes, and snippets.

@admc
Created July 28, 2013 23:41
Show Gist options
  • Save admc/6100750 to your computer and use it in GitHub Desktop.
Save admc/6100750 to your computer and use it in GitHub Desktop.
var User = function () {
this.hasMany('Messages');
this.hasMany('Conversations', {through: 'Messages'});
};
 
var Conversation = function () {
this.hasMany('Memberships');
this.hasMany('Users', {through: 'ConversationMemberships'});
};
 
var Message = function () {
this.belongsTo('Users');
this.belongsTo('ConversationMembership');
};
var ConversationMembership = function () {
this.belongsTo('User');
this.belongsTo('Conversation');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment