dimanche 1 février 2015

Returning polymorphic payload using RestSerializer

Say I have the following polymorphic relationships:



//animal.js
export default DS.Model.extend({});

//dog.js
import Animal from './animal';
export default Animal.extend({});

//cat.js
import Animal from './animal';
export default Animal.extend({});

//bird.js
import Animal from './animal';
export default Animal.extend({});


Now I want to fetch all the animals.



this.store.find('animal');


What should the JSON response be from the default RestSerializer given I want each polymorphic record to be transformed into its respective class? Currently all my records are converted to animal instances instead of their correct type.





Aucun commentaire:

Enregistrer un commentaire