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

Prisma · Module

updateMany

updateMany applies one set of field changes to every record matching a filter. It returns the number of records updated.

How it works

Call a model delegate's updateMany method with a where filter and a data object. Prisma applies the data changes to every record matching the filter and returns an object containing the number of updated records; bulk operations run transactionally.

Syntax

prisma.<model>.updateMany({ where, data })

Parameters

NameTypeDescription
whereModelWhereInputConditions selecting the records to update; the page documents this as the where argument.
dataXOR<ModelUpdateManyMutationInput, ModelUncheckedUpdateManyInput>Fields and values to apply to every selected record; the page documents this as the data argument.

Returns

A result object containing count, the number of records updated.

Key points

  • It changes multiple existing records in one bulk operation and reports the updated-row count.
  • The filter can use field conditions such as a substring match on an email field.
  • The data object supplies the new field values applied to each matching record.

Common mistakes

  • Do not put nested relation writes inside a top-level updateMany; use a supported nested write context or separate operations instead.

Example: Update matching users

const result = await prisma.user.updateMany({
  where: {
    email: { contains: "prisma.io" },
  },
  data: {
    role: "ADMIN",
  },
});

console.log(result.count);

Updates every matching user and prints the number of records changed.

When to use it

Bulk field updates

Change a field across a filtered group of existing records, such as assigning a role to users matching an email condition.

Batch state changes

Apply a status transition to all records meeting a business predicate, such as marking matching items processed.

Atomic batch workflows

Perform several independent writes with transactional behavior by combining bulk updates through Prisma's transaction API.

Interview questions

QWhat does updateMany do and what does it return?

updateMany performs a bulk update against all records selected by where, using the changes specified in data. Its result reports how many records were updated rather than returning the updated rows.

Follow-up: How can several independent updates be made atomic? Use Prisma's transaction API, such as $transaction([]), to execute them as one atomic operation.

QHow do where and data work together?

The where argument limits the records, while data describes the fields to change. For example, a filter can match users whose email contains a domain and assign those users an administrative role.

Follow-up: What should be considered when the filter is broad? Verify the predicate carefully because every matching record is changed in the bulk operation.

QAre bulk updates transactional, and can they contain nested writes?

Bulk operations, including updateMany, run as transactions. If a batch operation fails, the transaction behavior prevents a partial successful result within that operation.

Follow-up: How does this differ from nested writes? updateMany itself does not support nested writes, so related-record changes need a supported operation or separate transactional calls.

  • update
  • updateManyAndReturn
  • deleteMany
  • $transaction([])

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