Comments (3)
Wondering, why for the cascading destroying we can't just get the dependents list and for each using model.related().destroy() or map over them incase of model to destroy them?
That would make for a 1 more query on each cascade delete.
Rather then deleting children where foreign-key matches. We would fetch related data, map over them and destroy.
Could we somehow make it optional to delete with lifecycle hook?
from bookshelf-cascade-delete.
Hey @renarsvilnis!
So regarding your code snippets, the events are not triggered because this plugin does not fetch or even access the destroyed model's relations, it was only designed to execute delete queries for each dependent before executing its destroy
method though the foreign key.
Regarding your suggestion, as you said that would make one more query for each dependent and its dependents, which seems totally unnecessary unless you want to benefit from the events.
I understand this can be useful as an option, although I don't think I'll have time to explore its solution in a near future so I encourage you to dive in and implement it. WDYT?
from bookshelf-cascade-delete.
I'm closing this issue for lack of activity.
@renarsvilnis give a shout if you come up for a solution for this feature.
from bookshelf-cascade-delete.
Related Issues (13)
- Does not account for non-default idAttribute name HOT 1
- many to many, junction table. HOT 2
- Destroying with where clause HOT 1
- Error: Cannot find module 'babel-runtime/helpers/toConsumableArray' HOT 1
- Self relations HOT 11
- Can you release current master to npm? HOT 1
- Delete specific child of parent item
- Morph relations are not supported HOT 1
- Problem using registry plugin
- Gives a "TypeError: Cannot read property 'column' of undefined"
- Cascade delete many to many relations
- Fix default foreign key for PostgreSQL client HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bookshelf-cascade-delete.