So I thought this was kinda cool. There’s no such ...
# orm-help
a
So I thought this was kinda cool. There’s no such thing as cascading deletes in Prisma yet but I figured out that if you order your query properly and put an update before delete, you actually can get rid of associations before deleting the item you want to get rid of:
Copy code
return await db.project.update({
    data: {
      features: {
        update: { data: { featureDetails: { deleteMany: { featureId: id } } }, where: { id } },
        delete: { id },
      },
    },
    include: {
      company: true,
      features: { include: { featureDetails: { orderBy: { id: 'asc' } } } },
      invoices: true,
    },
    where: { id: projectId },
  })
💯 1
r
On the roadmap if you would like to check the progress 🙂
👍 1