Skip to content

Delete

delete() removes matching rows. Add where() to scope it.

await db.from(users).where("id", "=", 1).delete();

Omit where() to delete everything in the table:

await db.from(users).delete();
db.from(users).where("id", "=", 1).delete();
// → DELETE FROM "users" WHERE "id" = ?
export async function removeUser(id: number) {
await db.from(users).where("id", "=", id).delete();
}
  • Always scope deletes with where() unless you intend a full clear.
  • Consider a soft-delete (update({ deletedAt })) for recoverable data.
  • Wrap destructive deletes in a transaction when multiple tables are involved.
  • Forgetting where() and wiping the table.
  • Deleting without a FK ON DELETE strategy — orphans may remain.