Hi
I have a model like this:
App.Group = DS.Model.extend({
parent: DS.belongsTo('group', {inverse: 'items'}),
items: DS.hasMany('group', {inverse: 'parent'})
});
Now I have an instance of this group with a valid parent and I like to set the parent to null / undefined.
console.log(item.get('parent.id')) // prints the parents id
item.set('parent', null)
console.log(item.get('parent.id')) // prints undefined
item.save().then(() => console.log(item.get('parent.id'))) // prints the old parents id!
In the network request the old parent id is sent, so it is clear where the old parent id comes from after the item has beed saved. But why is the item saved with the old parent?
When I change the parent to another valid parent, it works as excepected. But how can I make the item have no parent? The parent item itself should not be removed.
I don’t know if it’s relevant, but I’m using the DS.RestAdapter with Ember Simple Auth.
Ember: 3.8.2
Ember Data: 3.8.0
Ember Simple Auth: 1.8.2
Thanks for your help.