Skip to content

Incorrect types when extending findMany with relations #2360

Answered by ryands17
JClackett asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @JClackett 👋
I have create the same with the following schema

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

model Post {
  id        String   @default(cuid()) @id
  published Boolean
  title     String
  content   String?
  author    User?    @relation(fields: [authorId], references: [id])
  authorId  Int?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

and on running this query, I get the following type

  const user = await prisma.user.findMany({
    include: {
      posts: true,
    },
  }

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@JClackett
Comment options

@ryands17
Comment options

Answer selected by JClackett
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