次のようなモデルがあるとします。
App.Parent = Ember.Model.extend(
children: DS.attr.hasMany('App.Child')
)
App.Child = Ember.Model.extend(
parent: DS.attr.belongsTo('App.Parent')
)
parent = App.Parent.find(1)
# How do I remove parent and all of it's children?
# This doesn't work since I'm removing elements from an array while iterating it
parent.get('children').forEach( c -> c.deleteRecord() )
parent.deleteRecord()
# Only removing the parent like this won't work either,
# Ember-data generates some strange PUT requests for every child
parent.deleteRecord()
# I guess I could do this, but it feels really awkward and
# wrong to use the adapter directly.
# And it also side-steps transactions making bulk updates impossible
App.store.adapter.deleteRecords(App.store, App.Child, parent.get('children'))
parent.deleteRecord()
App.store.commit()
もっと簡単な方法はありますか?親だけを削除するときに生成される奇妙な PUT リクエストは何ですか?