Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Confused by the upsert. #111

Answered by Brendonovich
teenjuna asked this question in Q&A
Jul 20, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

While admittedly the example in the docs may not be the easiest to understand, the structure is correct. To address your points individually:

  • Why provide the ID? Upsert exists to create a record if it doesn't exist, and if the record does exist then update it with the provided values. Prisma needs a unique field to determine whether the record exists or not and decide whether to create or update.
  1. It could be, but content in the create section is already specified as "upsert".to_string(). The example is meant to demonstrate assigning different values depending on whether the record exists or not.
  2. The structure of the arguments is upsert(where, create, update). where is the same argument…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@teenjuna
Comment options

@Brendonovich
Comment options

@teenjuna
Comment options

Answer selected by teenjuna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants