How to cascade delete an entity and all references to it in other entities
given a schema like this :
How do should I proceed to have the documentIds automatically removed from the modules when a document is deleted ?
I could add a call to the db in the
document:delete
query so it update the associated modules but I wonder if there is something more robust like a cascading option somewhere like in postgres5 Replies
Right now your options are:
1. In the mutation where you delete the module, also delete the documents.
2. Use Ents: https://labs.convex.dev/convex-ents
We might add a plugin for cascading deletes in the future.
Convex Ents - Convex Ents
Relations, default values, unique fields and more for Convex
I just found convex ents indeed and was going throught the documentation it seem to do what I need ! I will start the setup process
However it seems that its not very well used and I wonder about the maintain capabilities as its not convex team doing it.
Recently started using convex and it feel a bit scary to rely on convex-helpers and now this package.
I'm going through a migration to Ents now. I shared these concerns, but I looked through the Ents repo and it seems maintainable with respect to its importance to Convex's customer success.
(also both Ents and helpers are built by the folks on the Convex team - it's mostly a packaging decision that allows us to move faster on the edge of the platform)
there's another option now https://stack.convex.dev/triggers#cascade-deletes
Database Triggers
Triggers automatically run code whenever data in a table changes. A library in the convex-helpers npm package allows you to attach trigger functions t...