Skip to content

Instantly share code, notes, and snippets.

@benbabics
Last active January 22, 2016 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbabics/d54ad61d97dcd7ddc75b to your computer and use it in GitHub Desktop.
Save benbabics/d54ad61d97dcd7ddc75b to your computer and use it in GitHub Desktop.
{
"data": {
"id": "79931a85-9dda-42d8-8103-fea6ba4fc4af",
"type": "client",
"attributes": {
"name": "GrubHub",
"company-id": "grubhub",
"address": "111 W Washington St, Chicago, IL 60602",
"createdAt": "2016-01-20T18:40:46.000Z",
"updatedAt": "2016-01-21T23:25:58.000Z"
},
"relationships": {
"groups": {
"data": [{
"type": "group",
"id": "821e42f3-ac94-4585-80e6-f29186e6dcdc"
}]
}
}
},
"included": [{
"id": "821e42f3-ac94-4585-80e6-f29186e6dcdc",
"type": "group",
"attributes": {
"name": "My Test Group",
"spec": "c195f45d-fa99-4602-bbec-3c44421110a8",
"client": "79931a85-9dda-42d8-8103-fea6ba4fc4af",
"createdAt": "2016-01-21T14:20:40.000Z",
"updatedAt": "2016-01-21T14:20:40.000Z"
}
}]
}
export default DS.Model.extend({
groups: DS.hasMany( 'group' ),
name: DS.attr(),
address: DS.attr(),
});
export default DS.Model.extend({
client: DS.belongsTo( 'client' ),
spec: DS.belongsTo( 'spec', {async: true} ),
name: DS.attr()
});
model() {
return this.store.findAll( 'client' ).then( clients => clients.get('firstObject') );
}
export default DS.Model.extend({
additional: DS.attr( 'raw' ),
band: DS.attr( 'raw' ),
battery: DS.attr(),
camera: DS.attr(),
chipset: DS.attr(),
createdAt: DS.attr( 'date' ),
dimensions: DS.attr(),
display: DS.attr(),
memory: DS.attr(),
name: DS.attr(),
network: DS.attr( 'raw' ),
os: DS.attr(),
ruggedized: DS.attr( 'boolean' ),
storage: DS.attr(),
updatedAt: DS.attr( 'date' ),
variant: DS.attr(),
weight: DS.attr(),
});
<p>groups {{ model.groups }}</p> {!-- displays: <DS.PromiseManyArray:ember759> --}}
<p>group spec {{ model.groups.firstObject.spec }}</p> {!-- displays: <DS.PromiseObject:ember760> --}}
<p>group one name <strong>{{ model.groups.firstObject.name }}</strong></p> {!-- displays: My Test Group --}}
<p>group spec name <strong>{{ model.groups.firstObject.spec.content }}</strong></p> {!-- displays nothing --}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment