我在表中有数据,但prisma返回空响应。数据库托管在Planetscale上,它是MySQL。这是表的模式:
model BindingTeacherLessons {
bindingId Int
teacherId Int
lessons Int
binding Binding @relation(fields: [bindingId], references: [id], onDelete: Cascade)
teacher Teacher @relation(fields: [teacherId], references: [id], onDelete: Cascade)
@@id([bindingId, teacherId])
@@index([bindingId])
@@index([teacherId])
}
这个查询返回{}并且没有错误
const response = prisma.bindingTeacherLessons.findMany({})
问题似乎是我用createMany()填充了BindingTeacherLessons表。修复方法是使用create()填充它。