Guidance on properly cascading deletions
I'm working on converting the Ents SaaS Next.js Starter ( https://www.convex.dev/templates/ents-saas-starter ) away from Ents, because other than Ents it has everything I wanted. To do this I was reading about Ents, and came across this article talking about the challenges of deletion: https://stack.convex.dev/ents#cascading-deletes-soft-deletion-and-scheduled-deletion . It says:
This makes deletion in general more challenging though. You can easily have a scenario where a document’s ID is stored in 1000s or even more other documents. Deleting all of these documents in a single mutation, which is within a single transaction, is simply impossible, as it would require a long-lived transaction, grinding the whole database to a halt (something Convex does not allow, instead failing the mutation).So in conventional Convex, what's the suggested way to cascade a delete? I would prefer my app to not fail at deleting a workspace only when it has a lot of content in it. It'd be great to have an example exactly like the ents-saas-starter that doesn't use Ents, but that may be too much to ask. Thank you, -Jon
Convex Ents SaaS Next.js Starter
Build your SaaS website in no time! Included:
Realtime database for implementing your product with Convex
Team/organization management
Configurable roles and permissions
Member invite emails using Resend
User sign-in and sign-up with Clerk
Website router with Next.js
Slick UX with shadcn/ui
Convex Ents: Manage your document relationships
Convex Ents is a library that provides: simpler ways to model and query related documents, ability to easily map and filter documents, enforcing uniqu...
2 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
@aarku Since Convex Ents is build on top of vanilla Convex you could just use the Convex Ents implementation that power Convex Ents under the hood: https://github.com/xixixao/convex-ents/blob/main/src%2Fdeletion.ts
GitHub
convex-ents/src/deletion.ts at main · get-convex/convex-ents
Contribute to get-convex/convex-ents development by creating an account on GitHub.