adapters/foodoption.js
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
buildURL: function (modelType, id) {
return 'http://localhost:8080/getData' ;
},
handleResponse: function(status, headers, payload) {
payload = {foodoptions: payload};
return this._super(status, headers, payload);
}
});
models/foodoption.js
import DS from 'ember-data';
export default DS.Model.extend({
responsetype: DS.attr(),
responselists:DS.hasMany('responselist', { embedded: 'always' })
});
models/responselist.js
import DS from 'ember-data';
export default DS.Model.extend({
description: DS.attr(),
deleted:DS.attr()
});
serializers/foodoption.js
import DS from 'ember-data';
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
responselists: {embedded: 'always'}
}
});
Response from server:
{
"id":100,
"responsetype":"FOOD",
"responselist":[
{
"id":1,
"description":"One",
"deleted":"N"
},
{
"id":2,
"description":"Two",
"deleted":"N"
},
{
"id":3,
"description":"Three",
"deleted":"N"
}
]
}
Question: when I do this.store.findAll('foodoption'), only responsetype is loaded in model, responselist are not loaded from server response.
Am I missing something?
Aucun commentaire:
Enregistrer un commentaire