adelin-bA
Convex Community2y ago
5 replies
adelin-b

How to cascade delete an entity and all references to it in other entities

given a schema like this :

    modules: defineTable({
      name: v.string(),
      documentIds: v.array(v.id("documents")),
    })
    documents: defineTable({
      name: v.string(),
      content: v.optional(v.string()),
    })


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 postgres
Was this page helpful?