I have data in the table but prisma returns empty response. Database is hosted on Planetscale and it is MySQL. This is schema of the table:
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])
}
This query returns {} and no errors
const response = prisma.bindingTeacherLessons.findMany({})
It seems that the problem was that I have populated BindingTeacherLessons table with createMany(). Fix was to populate it with create().