I have extended the program given in this stackoverflow answer to have a program that deletes all the records all at once. However, the deletion happens only in batches and does not delete everything all at once.
Here is a snippet of the function I am using in this JSBin.
deleteAllOrg: function(){
this.get('store').findAll('org').then(function(record){
record.forEach(function(rec) {
console.log("Deleting ", rec.get('id'));
rec.deleteRecord();
rec.save();
});
record.save();
});
}
Any idea how the program can be modified such that all records can be deleted at once?
I have also tried model.destroy() and model.invoke('deleteRecords') but they don't work.
Any help is greatly appreciated. Thanks for your help!
Calling
deleteRecord()
withinforEach
will break the loop. You can fix it by wrapping the delete code in anEmber.run.once
function like this:See this jsBin.