I have the following code:
Pult.Zone = DS.Model.extend({
name: DS.attr('string'),
authoritative: DS.attr('boolean'),
user_id: DS.attr('number'),
rulesets: DS.hasMany('Pult.Ruleset')
});
Pult.RESTAdapter.map('Pult.Zone', {
primaryKey: 'name',
rulesets: { key: 'rulesetIds' }
});
However, it doesn't seem like is picking up on the primary key correctly. I have rendered a list of all zones.
Here's a test case:
zones = Pult.store.findAll(Pult.Zone);
zones.get('length'); // Returns 10
zones = Pult.store.findAll(Pult.Zone);
zones.get('length'); // Returns 20
So every time I load zones from the server, it adds them to the local list, since it does not recognize them as already existing. Any way to fix this, or will I have to try to mock up some surrogate keys?