I'm having a problem where an optional belongsTo relationship isn't properly pushed to store. In my Ember application I have a relationship between 2 models that is optional. For example imagine:
App.User = DS.Model.extend({
profile: DS.hasMany('profile', {'async': true})
});
App.Profile = DS.Model.extend({
user: DS.belongsTo('user', {'async': true})
});
where the "user" field in the "Profile" model can be empty. When it is empty, the serializer should return
....
relationships: {
user: null
}
...
in the normalized payload, at least if I have interpreted the JSON-API standard (JSON-API resource linkage) correctly. The problem is that this doesn't seem to be pushed to the store. I can reproduce this problem by
- Loading a "Profile" record from backend with relationship "user" set to null
- Changing the "user" value on the client side for that particular record to a non-null value
- Reloading the record from the backend
After these steps the "user" field on the "Profile" record still maintains its faulty, non-null value.
Is this expected behaviour or a bug? If this is expected behaviour, how should I track these changes in order to maintain data integrity?
Aucun commentaire:
Enregistrer un commentaire