I'm running into an issue with some very simple Ember setup. I have two separate models, appointment and item. My appointment model has a property, appointmentBins, which hasMany('item'). However, the array is always coming back empty and I have no idea why. Here are the relevant models:
// appointment model
let attr = DS.attr;
export default DS.Model.extend({
// ...
appointmentBins: DS.hasMany('item'),
confirmed: attr('boolean'),
specialInstructions: attr('string'),
// ...
});
// item model
let attr = DS.attr;
export default DS.Model.extend({
title: attr('string'),
userComments: attr('string'),
internalComments: attr('string'),
// ...
});
And here's the appointment serializer that I'm using:
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
isNewSerializerAPI: true,
attrs: {
appointmentBins: { serialize: 'ids', deserializer: 'records'},
// ...
}
});
And finally, here's the response from the network call:
appointment: {
appointment_bins: [,…]
0: {id: 27, title: "", user_comments: null, internal_comments: null, user_id: 23, item_category_id: 10,…}
1: {id: 28, title: "", user_comments: null, internal_comments: null, user_id: 23, item_category_id: 10,…}
2: {id: 29, title: "", user_comments: null, internal_comments: null, user_id: 23, item_category_id: 10,…}
3: {id: 30, title: "", user_comments: null, internal_comments: null, user_id: 23, item_category_id: 10,…}
confirmed: false
id: "f2eb7da8b2b31f2ebad0"
special_instructions: ""
// ...
}
I have no idea what I'm missing - this doesn't seem to be anything particularly complex, but I just can't parse the returned array inside the appointments model. Help greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire