Kadak

Delete

Understand soft vs hard delete semantics and use each path intentionally in production systems.

Delete

Kadak provides two delete paths: logical delete (delete) and physical delete (hardDelete).

Contract

db.users.delete(filter: Partial<User>): Promise<User[]>
db.users.hardDelete(filter: Partial<User>): Promise<User[]>

delete(filter)

Default delete route. If soft delete is enabled on the table, this updates the soft-delete column instead of removing rows.

const rows = await db.users.delete({ id: 1 })

If soft delete is not configured, delete() falls back to hard delete behavior.

hardDelete(filter)

Physical row removal from the table.

await db.users.hardDelete({ id: 1 })

Query behavior with soft delete

  • findMany() and findFirst() automatically exclude soft-deleted rows.
  • delete() becomes an update (deletedAt = now) when soft delete is enabled.

Production guardrails

  • Use delete() in normal product flows (recoverability, auditability).
  • Reserve hardDelete() for retention-policy cleanup and admin-only purge actions.
  • Keep delete filters narrow and explicit.

On this page