ember.jsember-data

Deleted records are not accessible


Given a model parent, that hasMany children.

How can I track deleted children? If ember keeps track of them, how I access them?

I have a complex form, where user can add/edit/delete children, but we have only one place to persists/cancel the parent. Is in this place where we persist/rollback also the children.

I can manually keep track of deleted records, but if Ember keeps track of them, I prefer to use ED.

I'm playing with something like that, but it's not working:

dirtyTasks: Ember.computed.filterBy('model.childs.@each.content', 'isDirty', true),
deletedTasks: Ember.computed.filterBy('model.childs.@each.content', 'isDeleted', true),
changedTasks: Ember.computed.union('dirtyTasks', 'deletedTasks'),


dirtyTasks: Ember.computed.filterBy('model.childs.@each', 'isDirty', true),
deletedTasks: Ember.computed.filterBy('model.childs.@each', 'isDeleted', true),
changedTasks: Ember.computed.union('dirtyTasks', 'deletedTasks'),


dirtyTasks: Ember.computed.filterBy('model.childs.[]', 'isDirty', true),
deletedTasks: Ember.computed.filterBy('model.childs.[]', 'isDeleted', true),
changedTasks: Ember.computed.union('dirtyTasks', 'deletedTasks'),

Also, in the inspector, I can see the content.canonicalState, content.currentState, which are arrays with the rows, but sure there is an easier way like: model.get('childs.deletedRecords') or something similar?

thanks

Same question but it's not clear to me how to solve it


Solution

  • Ok, finally found the solution in Slack ...

    model.get('children').filterBy('isDeleted')