Ember 2.4.0
Ember Data 2.4.0
so I'm trying to return an object "api-user-list" that is comprised of two models, a pager object named "pager" and a collection of users called "api-user"
pager model
import DS from 'ember-data';
import { belongsTo } from 'ember-data/relationships';
export default DS.Model.extend({
PageSize: DS.attr(),
SkipPages: DS.attr(),
SearchStr: DS.attr(),
TotalCount: DS.attr(),
PageCount: DS.attr()
});
apiUser Model
import DS from 'ember-data';
export default DS.Model.extend({
UserName: DS.attr(),
First: DS.attr(),
Last: DS.attr(),
Bio: DS.attr(),
OrgId: DS.attr(),
CreatedAt: DS.attr(),
DeActivatedAt: DS.attr(),
PasswordSetAt: DS.attr(),
PhoneNumber: DS.attr()
});
the complex model "api-user-list"
import DS from 'ember-data';
import Model from 'ember-data/model';
import { belongsTo, hasMany } from 'ember-data/relationships';
export default Model.extend({
pager: belongsTo('pager', { async: false }),
apiUser: hasMany('api-user', { async: false })
});
returned JSON
{
"apiUserList": {
"id": 1,
"pager": {
"id": 1,
"PageSize": 2,
"SkipPages": 0,
"SearchStr": null,
"TotalRecords": 2,
"TotalPages": 1
},
"apiUser": [
{
"id": 3,
"UserName": "dude 2",
"First": "Allen",
"Last": "Smith",
"Bio": null,
"OrgId": 0,
"CreatedAt": "2016-07-14T19:27:20.757",
"DeActivatedAt": null,
"PasswordSetAt": "2016-07-14T19:32:38.34",
"PhoneNumber": null
},
{
"id": 2,
"UserName": "dummyUser",
"First": "dude",
"Last": "dude last name",
"Bio": null,
"OrgId": null,
"CreatedAt": "2016-07-08T10:53:35.017",
"DeActivatedAt": null,
"PasswordSetAt": "2016-07-27T16:07:35.073",
"PhoneNumber": null
}
]
}
}
it looks like the correct model is being returned but get an error when the "pager" is trying to be pushed into the store:
Assertion Failed: You need to pass a model name to the store's modelFor method
in the debugger I can see that I enter
function deserializeRecordId()
but when it tries to read the id.type variable it's always 'undefined'. Does anyone have an idea where I am missed something?
Aucun commentaire:
Enregistrer un commentaire