capabilities.work

Client Upsert a Record

A 2-step recipe with Prisma. We can help you get access.

Recipe · 2 steps

Client Upsert a Record

with Prisma
Works with AI assistants

Find a record by id and upsert it, creating when absent or updating when present.

  1. Attempt to read the record by its unique id, branching on whether it already exists.
  2. Upsert the record using the where condition. When a matching record exists the update payload is applied; otherwise the create payload is used to insert a new record.
What you'll need to have ready
  • model: The Prisma model name (e.g. user, post).
  • id: Unique identifier of the record to look up.
  • where: Unique condition used by the upsert to match an existing record.
  • createData: Field values to use when creating a new record.
  • updateData: Field values to use when updating an existing record.
For your developer

Arazzo workflow prisma:upsert-record, 2 operations: findUnique → upsert. Specs on APIs.io.