Get started
Overview PostgreSQL MySQL SQLite Manage schema
Overview Column types Indexes & Constraints Migrations Views Schemas Access your data
Query Select Insert Update Delete Filters Joins Magic sql`` operator Performance
Queries Serverless Advanced
Set Operations Transactions Batch Dynamic query building Read Replicas Custom types Goodies Extensions
ESLint Plugin drizzle-zod drizzle-typebox drizzle-valibot SQL Delete
You can delete all rows in the table:
await db.delete(users);
And you can delete with filters and conditions:
await db.delete(users).where(eq(users.name, 'Dan'));
Delete with return
PostgreSQL
SQLite
MySQL
You can delete a row and get it back in PostgreSQL and SQLite:
const deletedUser = await db.delete(users)
.where(eq(users.name, 'Dan'))
.returning();
// partial return
const deletedUserIds: { deletedId: number }[] = await db.delete(users)
.where(eq(users.name, 'Dan'))
.returning({ deletedId: users.id });