#Planetscale relation query issue

1 messages · Page 1 of 1 (latest)

gloomy dock
#

I am trying to fetch data from relation table but prisma shows error: "message": "\nUnknown field posts for include statement on model Channel.",

Planetscale prisma Schema:

  id          String          @id @default(cuid())
  title       String
  posts       Post[]
}

model Post {
  id          String   @id @default(cuid())
  title       String
  channelId   String   @map(name: "channel_id")
  channel     Channel  @relation(fields: [channelId], references: [id])
  @@index([channelId])
}

Query with error:

await prisma.channel.findMany({
  include: {
  posts: true
  },
  where: {
    "id": "example"
  },
  take: 100 
})

how can i resolve this ?

true wedge
#

That looks like it should work correctly. Have you made sure you re-generated Prisma Client and that the schema is applied to your database?

heady radish
true wedge
#

@gloomy dock Did this solve the prob ^

gloomy dock
#

not resolved yet, I am already using relationMode = "prisma".

gloomy dock