Code Monkey home page Code Monkey logo

Comments (3)

renarsvilnis avatar renarsvilnis commented on September 25, 2024

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.

ricardogama avatar ricardogama commented on September 25, 2024

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.

ricardogama avatar ricardogama commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.