pictorally, the relationship is: ```comment --&gt...
# orm-help
g
pictorally, the relationship is:
Copy code
comment --> post --> site
a
Copy code
await prisma.post.findMany({ where: { siteId: siteId }, include: { comments: true } })
That’ll get all posts for a site and load all comments for each post.
I think this should also work:
Copy code
await prisma.comment.findMany({ where: { post: { siteId: siteId } } })
👍 1
n
Hey Giorgo, there are several ways how you can query this data and I think Aaron's latest suggestion is probably the most concise one:
Copy code
const commentsBySite = await prisma.comment.findMany({
  where: {
    post: {
      site_id: 'ckfxix6rw00035lzkgilqgjtm',
    },
  },
})
g
I've tried those approaches but I keep getting type errors 🤔 I'll see what I could have done wrong on my end because my intuition led me to the same suggestions that you two posted! Thank u!
figured out that the type errors I was getting was because I had a
output
field in my
generator
directive, and I was importing
PrismaClient
from the wrong location initially!
👍 2