Skip to content

Instantly share code, notes, and snippets.

@teddyzeenny
Last active December 17, 2015 12:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teddyzeenny/5613485 to your computer and use it in GitHub Desktop.
Save teddyzeenny/5613485 to your computer and use it in GitHub Desktop.
Deleting a parent when you have `dependent: :destroy` on the server
// Deleting a parent when you have `dependent: :destroy` on the server
// given `parent` a parent record
// `children` the parent's children
var childrenTransaction, parentTransaction;
childrenTransaction = this.get('store').transaction();
childrenTransaction.add(parent);
parent.deleteRecord();
parentTransaction.add(parent);
parent.one('didDelete', function() {
chilren.forEach(function(child) {
child.get('stateManager').send('becameClean');
child.get('stateManager').send('finishedMaterializing');
child.unloadRecord();
});
});
parentTransaction.commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment