How to get removed models for delete their from backend?


I have model which has hasMany relationship - points. In template I render objects from this relationship. And when I want to remove one point from routePoints I do it like this:

removePoint(point) {

  if (point.get('isNew')) {
  } else {

And then if user will save model I will delete removed points from backend:

// Inside save action
model.hasMany('points').hasManyRelationship.canonicalState.forEach(function(point) {
  if (point.isDeleted()) {;

I’m not sure I’m doing it right. How can I get deleted model from store another way? Is there a more correct practice?

you can use filterBy to get the deleted points (and use invoke to shorten the function even more):


Thank you for answer, but it won’t be work.I remove point from model.points.

Then the question is not clear for me. In your last sentence you asked to get deleted models from store. But you can also do:


No I can’t, becouse I remove point from points


Now I understand. Sorry for my wrong answer and unfortunately I don’t know another solution. In one of my apps I’m solving this issue on the backend.

you should instead invoke deleteRecord(), followed by save().

please refer

Nope. I must remove all deleted points only after user will click “Save” button. In save action I save main model and all new/edited/deleted points.

  1. In removePoint() method, You might want to use a temporary array for holding ‘deleted’ records.
  2. while saving parent record, iterate over the array and invoke destroyRecord() on each of them.