Created
October 16, 2018 19:20
-
-
Save luxzeitlos/1d5e858b082ffa7e2ea44b84feff5389 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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.Adapter.extend({ | |
findAll() { | |
return { | |
genres: [ | |
{"id":1,"name":"Action"}, | |
{"id":2,"name":"Adventure"}, | |
{"id":3,"name":"Animation"}, | |
{"id":4,"name":"Comedy"}, | |
] | |
}; | |
} | |
}); |
This file contains hidden or 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.Adapter.extend({ | |
findAll() { | |
return { | |
results: [{ | |
"id":1, | |
"title": "Venom", | |
"genre_ids": [1,2,3], | |
},{ | |
"id":2, | |
"title": "Example Movie", | |
"genre_ids": [3,4], | |
}], | |
}; | |
} | |
}); |
This file contains hidden or 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'), | |
}); |
This file contains hidden or 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({ | |
title: attr('string'), | |
genres: hasMany('genre'), | |
}); |
This file contains hidden or 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 RSVP from 'rsvp'; | |
export default Ember.Route.extend({ | |
model() { | |
return RSVP.hash({ | |
genres: this.store.findAll('genre'), | |
movies: this.store.findAll('movie'), | |
}).then(x => x.movies); | |
} | |
}); |
This file contains hidden or 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.JSONSerializer.extend({ | |
normalizeArrayResponse (store, primaryModelClass, payload, id, requestType) { | |
return this._super(store, primaryModelClass, payload.genres, id, requestType); | |
} | |
}); |
This file contains hidden or 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'; | |
import {singularize} from 'ember-inflector'; | |
export default DS.JSONSerializer.extend({ | |
normalizeArrayResponse (store, primaryModelClass, payload, id, requestType) { | |
return this._super(store, primaryModelClass, payload.results, id, requestType); | |
}, | |
keyForRelationship(key, typeClass, method) { | |
return `${singularize(key)}_ids`; | |
} | |
}); |
This file contains hidden or 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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment