I was wondering if it is possible to create a transform for belongsTo (and by extend hasMany) as my REST server returns relationships that are defined like this:
import DS from 'ember-data';
export default DS.Model.extend({
lastname: DS.attr('string'),
firstname: DS.attr('string'),
company: DS.belongsTo('company'),
});
this way:
[
{
"firstname": "John",
"lastname": "Doe",
"company": {
"uri": "<snip>/api/rest/company/5",
"id": "5",
"resource": "company"
}
}
]
while the default implementation for the RESTAdapter expects the server to respond like this:
[
{
"firstname": "John",
"lastname": "Doe",
"company": "5"
}
]
Aucun commentaire:
Enregistrer un commentaire