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

Prisma · Function

prisma.update

prisma.model.update() changes one existing record selected by a unique filter and returns the updated record. Its data object can include scalar changes and supported nested relation operations.

How it works

Call a model's update method with a unique where filter and a data object containing the fields or nested operations to apply. The operation updates one existing record and returns the resulting record; use updateMany for bulk changes.

Syntax

prisma.<model>.update({ where: <ModelWhereUniqueInput>, data: <XOR<ModelUpdateInput, ModelUncheckedUpdateInput>> })

Parameters

NameTypeDescription
whereModelWhereUniqueInputUnique filter identifying the existing record to update.
dataXOR<ModelUpdateInput, ModelUncheckedUpdateInput>Field values and supported nested operations to apply to the record.

Returns

The updated model record.

Key points

  • The data argument contains the model fields to change; optional or defaulted fields may be omitted.
  • The method is asynchronous and is normally awaited to obtain the updated record.
  • Nested updates let a parent update include changes to related records.

Common mistakes

  • Do not use update when the intent is a bulk update: updateMany is the batch-oriented operation and returns a count rather than updated objects.
  • Nested update operations can modify related records through the parent update, so check the relation shape and parent identifier carefully.

Example: Update one record

const user = await prisma.user.update({
  where: { email: "viola@prisma.io" },
  data: { name: "Viola the Magnificent" },
});

Updates one uniquely identified User record and returns the updated record.

When to use it

Update a single record

Change fields on one known record selected by a unique identifier.

Perform a nested relation update

Modify a parent and supported related records in one query.

Interview questions

QWhat is the purpose of Prisma's update method?

Use update when exactly one existing record should be changed. The where argument selects it with a unique filter, while data specifies scalar changes or supported nested operations; the updated record is returned.

Follow-up: How would you update many records? Use updateMany with a filter and data object; it performs a bulk update and returns the number of affected records.

QWhat do the where and data arguments do?

where identifies the target record, and data contains the update payload. Fields that are optional or have defaults in the data model can be omitted from the update input.

Follow-up: What is the difference between data and where? data describes changes, whereas where determines which unique record receives them.

QCan update modify related records?

A nested update can change related records as part of updating a parent record. This supports composing a parent update with relation changes in one Prisma Client query.

Follow-up: How can related records be updated in bulk? A nested updateMany can update all matching related records for a particular parent.

  • updateMany
  • updateManyAndReturn
  • ModelWhereUniqueInput
  • ModelUpdateInput
  • nested update

Source: Prisma Client API (Prisma ORM v7). Checked 2026-10-16.