【问题标题】:How to filter for related objects in Prisma?如何过滤 Prisma 中的相关对象?
【发布时间】:2023-03-23 14:57:02
【问题描述】:

如何在 Prisma 中查询关系?我有以下架构:

model User {
  id      Int      @id @default(autoincrement())
  name    String?
  profile Profile 
}

model Profile {
  id     Int    @id @default(autoincrement())
  user   User   @relation(fields: [userId], references: [id])
  userId Int
}

如何在Profile 中查询特定的User

【问题讨论】:

    标签: prisma


    【解决方案1】:

    自己找到了答案:

    prisma.user.findUnique({ where: { id: 42 }}).profile()
    

    【讨论】:

      猜你喜欢
      • 2021-03-07
      • 2012-08-07
      • 1970-01-01
      • 2020-10-13
      • 2010-09-20
      • 2019-02-14
      • 2016-05-01
      • 1970-01-01
      相关资源
      最近更新 更多