如何通过过滤获得帖子tagId
?
我测试了这段代码,但它不起作用:我得到了所有没有过滤的帖子!
prisma.post.findMany({
include:
{
Tags:
{
where: { TagId: tagId },
include:
{
Tag: true
}
}
},
})
架构.棱镜:
model Post {
id Int @id @default(autoincrement())
title String
tags PostTags[]
}
model PostTags {
id Int @id @default(autoincrement())
post Post? @relation(fields: [postId], references: [id])
tag Tag? @relation(fields: [tagId], references: [id])
postId Int?
tagId Int?
}
model Tag {
id Int @id @default(autoincrement())
name String @unique
posts PostTags[]
}
我该如何解决这个问题?