Prisma returns empty response when fetching data

710 Views Asked by At

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({})
1

There are 1 best solutions below

1
On

It seems that the problem was that I have populated BindingTeacherLessons table with createMany(). Fix was to populate it with create().