In this exmaple case, a single Ball
either belongsTo
Football
, or it belongsTo
Soccer
.
App.Football = DS.Model.extend({
name: DS.attr('string'),
balls: DS.hasMany('balls', { inverse: 'sport' })
});
App.Soccer = DS.Model.extend({
name: DS.attr('string'),
balls: DS.hasMany('balls', { inverse: 'sport' })
});
App.Ball = DS.Model.extend({
color: DS.attr('string'),
sport: DS.belongsTo('No idea what goes here', { inverse: 'balls' }),
sportType: 'No idea what goes here'
});
Is there a way to represent this in Ember.js? And would the Ball
need a sportType
to differentiate between store.find('football', 1)
and store.find('soccer', 1)
?