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. https://guides.emberjs.com/v2.12.0/models/creating-updating-and-deleting-records/#toc_deleting-records
  2. https://guides.emberjs.com/v2.12.0/models/relationships/#toc_removing-relationships

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