Skip to content

Instantly share code, notes, and snippets.

@phillipkregg
Last active August 10, 2016 16:21
Show Gist options
  • Save phillipkregg/bc129669e37a46002420141cfa1bbfa1 to your computer and use it in GitHub Desktop.
Save phillipkregg/bc129669e37a46002420141cfa1bbfa1 to your computer and use it in GitHub Desktop.
Store Albums
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
title: attr(),
artist: attr(),
songCount: attr()
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
this.get('store').push({
data: [{
id: 1,
type: 'album',
attributes: {
title: 'Fewer Moving Parts',
artist: 'David Bazan',
songCount: 10
},
relationships: {}
}, {
id: 2,
type: 'album',
attributes: {
title: 'Calgary b/w I Can\'t Make You Love Me/Nick Of Time',
artist: 'Bon Iver',
songCount: 2
},
relationships: {}
}]
});
debugger;
return this.store.find('album', 1)
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{log model}}
{{#each model as |album|}}
<li>{{album}}</li>
{{/each}}
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment