emberjs/data — Issue #67: ER: Children Model Support
Author: pixelcort
Created: 2012-01-26 20:57:41+00:00
State: open

I have data from the server like:

{
"id": 1,
"name": "Bob",
"tags": [
{
"id": 10,
"name": "Happy",
"color": "Green"
},
{
"id": 11,
"name": "Sleepy",
"color": "Blue"
}
]
}

I'd like to do something like the following:

App.Tags = DS.Model.extend({
primaryKey: 'id'
});
App.People = DS.Model.extend({
primaryKey: 'id',
name: DS.attr('string'),
tags: DS.childrenAttr(App.Tags)
});

and then when I do ```var happy = person.get('tags').get('firstObject')``` I'd like to be able to call ```happy.set('color','Yellow')``` which would cause ```person.data.tags[0].color === 'Yellow'```.