Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested upsert example missing where clause #6274

Closed
jyasskin opened this issue Sep 21, 2024 · 1 comment
Closed

Nested upsert example missing where clause #6274

jyasskin opened this issue Sep 21, 2024 · 1 comment
Labels
docs Documentation creation, updates or corrections

Comments

@jyasskin
Copy link

jyasskin commented Sep 21, 2024

Sorry if I'm just misunderstanding this, but in https://www.prisma.io/docs/orm/prisma-client/queries/relation-queries#update-or-create-a-related-record, it looks like the upsert object has the required create and update fields, but it's missing the required where field.

@jyasskin jyasskin added the docs Documentation creation, updates or corrections label Sep 21, 2024
@nikolasburk
Copy link
Member

nikolasburk commented Oct 1, 2024

Hey @jyasskin 👋

Thanks a lot for opening this issue! This is indeed a misunderstanding:

  • you are referring the query called upsert which indeed requires a where clause to identify the record that potentially gets updated
  • however, this page is about the option called upsert inside the query called update and hence doesn't require a where clause (because the record to be updated is identified through the 1-n-relation)

You can test this by setting up a simple Prisma ORM project and this schema:

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  content   String?
  published Boolean  @default(false)
  author    User?    @relation(fields: [authorId], references: [id])
  authorId  Int?
}

Then try to use the query you refer to in the docs and you'll see the behaviour as expected.

Let us know if you have any further questions, we're always happy to help 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation creation, updates or corrections
Projects
None yet
Development

No branches or pull requests

2 participants