Ember data: Revert belongsTo destroy

Suppose I have two models, parent and child which share a belongsTo relationship.

models/parent.js
{
    child: belongsTo('')
}
models/child.js
{
    parent: belongsTo('')
}

In one of my controllers, I want to destroy the two records, so I have code which does something like,

model.get('child').destroyRecord()
    .then(() => {
         model.destroyRecord();
    });

How do I revert the delete on the child if the parent’s model.destroyRecord() fails? What is the preferred approach to revert dependent relationship deletes?

destroyRecord invokes DELETE on the backend.

You might want to do a deleteRecord, and then followed by save if every thing goes fine.

Please refer

  1. Creating, Updating and Deleting - Models - Ember Guides
  2. Relationships - Models - Ember Guides

That still doesn’t solve the failure problem as any of the two saves could fail.