Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Function

prisma.delete

Prisma Client's delete removes one existing record selected by ID or another unique attribute. It returns the deleted record, with select or include available to control the returned shape.

How it works

Call the model delegate's delete method with a where object identifying exactly one record by its ID or another unique field. Prisma removes that record and returns the deleted record; use select to restrict returned fields, while related-record behavior depends on the configured relation rules.

Syntax

prisma.<model>.delete({ where: <ModelWhereUniqueInput>, select?: <ModelSelect>, include?: <ModelInclude> })

Parameters

NameTypeDescription
whereModelWhereUniqueInputUnique selector identifying the single record to delete; typically contains an ID or another unique field.
selectModelSelectOptional field projection controlling which fields are returned from the deleted record.
includeModelIncludeOptional relation and field projection controlling the returned record shape.

Returns

A Promise resolving to the deleted record, shaped by select or include; the operation throws if no uniquely matching record exists or referential constraints prevent deletion.

Key points

  • delete removes one existing database record.
  • An ID can identify the record to remove.
  • A unique attribute, such as a unique email, can identify the record instead of its ID.
  • Use select when the caller needs only chosen fields from the deleted record.
  • Nested delete can remove a related record during a parent write.

Common mistakes

  • Use deleteMany instead of delete when the operation should target records matching a general filter rather than one uniquely identified record.
  • A nested delete removes the related child record only; it does not remove the parent record.

Example: Delete one user and select returned fields

const deletedUser = await prisma.user.delete({
  where: { email: "elsa@prisma.io" },
  select: { id: true, name: true, email: true },
});
console.log(deletedUser);

Deletes the uniquely identified user and returns only the selected fields from the deleted record.

When to use it

Delete by ID

Remove a user after locating it by its primary key.

Delete by a unique attribute

Remove a record identified by a unique email, username, or other unique field.

Nested relation deletion

Remove a related child during a nested write without deleting its parent.

Project the deleted record

Return only fields needed by the caller after deletion.

Interview questions

QWhat does Prisma Client's delete operation do?

delete removes one existing record identified through where, which can use an ID or another unique attribute. It returns the deleted record, and select can limit the returned fields.

Follow-up: How would you remove all users with a matching email domain? Use deleteMany with a filter, because delete requires a uniquely identifying condition.

QWhich records can delete target?

The where input must identify a single record through a unique field, such as id or a unique email. A non-unique general criterion belongs with deleteMany.

Follow-up: What happens if several records satisfy a non-unique condition? delete is not the appropriate operation; use deleteMany to target the matching set.

QWhat relationship constraint can prevent deletion?

A parent deletion can fail when required related records still exist, such as posts that require an author. Related records must be deleted first, or the schema must use appropriate referential actions such as cascading behavior.

Follow-up: How can multiple dependent deletions remain atomic? Put the separate delete operations in a transaction so they succeed or roll back together.

  • deleteMany
  • select
  • include
  • where
  • $transaction
  • referential actions

Source: Prisma Client API. Checked 2026-10-16.