@Hummingbird wrote:
I am having a one to many relationship, which looks like this:
models/group.js:
export default DS.Model.extend({ members: DS.hasMany('member', { async: true }) })
models/member.js:
export default DS.Model.extend({ group: DS.belongsTo({ inverse: 'members' }) })
Each model has a dedicated resource server side and is loaded separately. This has always worked well so far. However, I was trying to find a way to easily figure out which of these resources have been updated since the last visit. To get that information there already is an event resource available, which contains notifications about the updated entity.
So I added a relationship to the event model:
models/event.js:
export default DS.Model.extend({ group: DS.belongsTo({ async: true }), member: DS.belongsTo({ async: true }), })
The server sends the group id or the member id within the group or member field.
The member and group model respectively contain a relationship to the events, so I just need to check if there are any events attached to the model to find out if and which updates have happened:models/member.js:
export default DS.Model.extend({ group: DS.belongsTo({ inverse: 'members' }), events: DS.hasMany('event') })
If the member now has an event attached to what happens is the following: The event is loaded before the group and members are loaded. Ember somehow creates a new member record which just contains the id of the member and the events relationship. All other values are default values. Ember then thinks it already has loaded this entity and even when navigating to the route the member never gets loaded from the server. Is there anything I can do to make this work in a clean way or is this a sort of a bug somehow?
ember data is 2.11.3
Posts: 6
Participants: 2