Following my previous question here, is there a way to have the same behaviour as ON DELETE CASCADE
(MySQL) with JayData?
If I delete a Test I would like all linked Chapters and Checks to be deleted. I tried this code:
myDB.onReady(function(){
myDB.Tests.filter(function(test) { return test.Name == this.Name; }, {Name: myTest.Name}).forEach(function(test){
console.log('Starting to remove '+test.Name);
myDB.Tests.remove(test);
myDB.saveChanges(function() {
console.log(test.Name+' removed');
});
});
});
But it doesn't delete the children. Could it be linked with the declaration of Chapters
and Checks
in the context? JayData probably doesn't see them as children but as independent entities.
I've also seen somewhere that there is some configuration required to do cascading operations with SQLite. I guessed JayData would deal with that.