Created
March 25, 2017 17:16
-
-
Save topaxi/bbeb5040ebe8e342ecf854199e1bb0a6 to your computer and use it in GitHub Desktop.
Ember Data Included Issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.JSONAPIAdapter.extend({ | |
namespace: 'api', | |
coalesceFindRequests: false | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function() { | |
this.urlPrefix = ''; | |
this.namespace = 'api'; | |
this.timing = 400; | |
this.resource('playlists'); | |
this.resource('playlist-tracks'); | |
this.resource('artists'); | |
this.resource('tracks'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Factory, faker } from 'ember-cli-mirage'; | |
export default Factory.extend({ | |
name: i => `Playlist ${i + 1}` | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default [ | |
{ id: 'parkway-drive', name: 'Parkway Drive' }, | |
{ id: 'goldfinger', name: 'Goldfinger' }, | |
{ id: 'pennywise', name: 'Pennywise' }, | |
{ id: 'in-flames', name: 'In Flames' }, | |
{ id: 'talco', name: 'Talco' }, | |
{ id: 'nofx', name: 'NOFX' }, | |
{ id: 'authority-zero', name: 'Authority Zero' }, | |
{ id: 'disturbed', name: 'Disturbed' }, | |
{ id: 'breakdown-of-sanity', name: 'Breakdown of Sanity' }, | |
{ id: 'honningbarna', name: 'Honningbarna' }, | |
{ id: 'morcheeba', name: 'Morcheeba' }, | |
{ id: 'no-use-for-a-name', name: 'No Use for a Name' }, | |
{ id: 'the-suicide-machines', name: 'The Suicide Machines' }, | |
{ id: 'mad-caddies', name: 'Mad Caddies' }, | |
{ id: 'rise-against', name: 'Rise Against' }, | |
{ id: 'no-fun-at-all', name: 'No Fun at All' }, | |
{ id: 'billy-talent', name: 'Billy Talent' }, | |
{ id: 'rage-against-the-machine', name: 'Rage Against the Machine' }, | |
{ id: 'noisia', name: 'Noisia' }, | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default [ | |
{ artistId: 'parkway-drive', title: 'Crushed' }, | |
{ artistId: 'parkway-drive', title: 'Idols and Anchors' }, | |
{ artistId: 'parkway-drive', title: 'Wild Eyes' }, | |
{ artistId: 'parkway-drive', title: 'Alone' }, | |
{ artistId: 'parkway-drive', title: 'Dream Run' }, | |
{ artistId: 'parkway-drive', title: 'Sleepwalker' }, | |
{ artistId: 'parkway-drive', title: 'Home Is For The Heartless' }, | |
{ artistId: 'parkway-drive', title: 'Carrion' }, | |
{ artistId: 'parkway-drive', title: 'Frostbite' }, | |
{ artistId: 'parkway-drive', title: 'Wreckage' }, | |
{ artistId: 'goldfinger', title: 'Behind the Mask' }, | |
{ artistId: 'goldfinger', title: 'Get Up' }, | |
{ artistId: 'goldfinger', title: 'Superman' }, | |
{ artistId: 'goldfinger', title: 'Handjobs For Jesus' }, | |
{ artistId: 'goldfinger', title: 'Open Your Eyes' }, | |
{ artistId: 'goldfinger', title: 'Spokesman' }, | |
{ artistId: 'goldfinger', title: 'My Everything' }, | |
{ artistId: 'goldfinger', title: 'Carry Open' }, | |
{ artistId: 'goldfinger', title: 'Goodbye' }, | |
{ artistId: 'goldfinger', title: 'Here In Your Bedroom' }, | |
{ artistId: 'pennywise', title: 'Fuck Authority' }, | |
{ artistId: 'pennywise', title: 'My God' }, | |
{ artistId: 'pennywise', title: 'Divine Intervation' }, | |
{ artistId: 'pennywise', title: 'Enemy' }, | |
{ artistId: 'pennywise', title: 'Anyone Listening' }, | |
{ artistId: 'pennywise', title: 'Punch Drunk' }, | |
{ artistId: 'pennywise', title: 'God Save the USA' }, | |
{ artistId: 'pennywise', title: 'Afflication' }, | |
{ artistId: 'pennywise', title: 'Rise Up' }, | |
{ artistId: 'pennywise', title: 'Society' }, | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, hasMany } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
tracks: hasMany() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, belongsTo } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
track: belongsTo(), | |
playlist: belongsTo() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, hasMany } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
playlistTracks: hasMany() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, belongsTo, hasMany } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
artist: belongsTo(), | |
playlistTracks: hasMany() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { faker } from 'ember-cli-mirage' | |
export default function(server) { | |
server.loadFixtures('playlists', 'artists', 'tracks') | |
server.createList('playlist', 10).forEach(playlist => { | |
for (let i = faker.random.number({ min: 1, max: 30 }); i--;) { | |
server.create('playlist-track', { | |
playlistId: playlist.id, | |
trackId: faker.random.number({ min: 1, max: 30 }), | |
order: i | |
}) | |
} | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { JSONAPISerializer } from 'ember-cli-mirage'; | |
export default JSONAPISerializer.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
tracks: hasMany('track', { inverse: 'artist' }), | |
name: attr('string') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
track: belongsTo('track'), | |
playlist: belongsTo('playlist'), | |
note: attr('string'), | |
order: attr('number') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
name: attr('string'), | |
playlistTracks: hasMany('playlist-track'), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
artist: belongsTo('artist'), | |
playlistTracks: hasMany('playlist-track', { inverse: 'track' }), | |
title: attr('string') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('playlist', { path: '/:id' }) | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return this.store.findAll('playlist'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model({ id }) { | |
return this.store.findRecord('playlist', id, { | |
include: 'playlist-tracks.track.artist' | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"ENV": { | |
"ember-cli-mirage": { | |
"enabled": true | |
} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1", | |
"ember-cli-mirage": "0.3.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment