bookshelf-cascade-delete icon indicating copy to clipboard operation
bookshelf-cascade-delete copied to clipboard

Cascade delete many to many relations

Open antoniovini opened this issue 4 years ago • 0 comments

I'm trying to delete all objects in the list, but only the support table and the news table itself are deleted

bookshelf.model('News', {
    tableName: 'news',
    files(){
      return this.belongsToMany('Files').through('NewsFiles');
    },
  }, {
    dependents: ['files']
});

delete:

await models.news.where({ id }).destroy({ cascadeDelete: true });

the files entry is not destroyed.

antoniovini avatar Aug 19 '20 20:08 antoniovini