#astro db onDelete

3 messages · Page 1 of 1 (latest)

lament walrus
#

How can I set onDelete: 'cascade' when creating a table that references a foreign key?

solemn kiteBOT
#

Hi @lament walrus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

I apologize, but the knowledge sources provided do not contain specific information about setting onDelete: 'cascade' when creating a table with a foreign key reference in Astro DB.

However, the documentation does mention how to create foreign key references in Astro DB tables. According to the Astro DB guide (https://docs.astro.build/en/guides/astro-db/#define-your-database), you can establish relationships between tables using reference columns. Here's an example of how to create a basic foreign key reference:

const Author = defineTable({
  columns: {
    id: column.number({ primaryKey: true }),
    name: column.text(),
  }
});

const Comment = defineTable({
  columns: {
    authorId: column.number({ references: () => Author.columns.id }),
    body: column.text(),
  }
});

Unfortunately, the provided documentation does not mention an onDelete option or cascading deletes. If you need this specific functionality, you may want to check the latest Astro DB documentation or reach out to the Astro community for more information, as it's possible this feature might be available but not covered in the provided knowledge sources.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: