PDA

View Full Version : Can the same model be under hasMany and belongsTo associations?



michael.parrott
25 Jul 2012, 12:00 PM
If I have a model, SportsTeam, and another model, Player, is it possible for a Player to both belong to and have many teams?


Ext.define( 'App.model.Player',{
extend: 'Ext.data.Model',

config:
{
hasMany: 'Team',
belongsTo: 'Team'
}
} );

I'm thinking this may not work because a player would need to belong to multiple teams, and just having the hasMany config set to 'Team' would work.

mitchellsimoens
27 Jul 2012, 6:44 AM
I can't think of a reason why it couldn't work.