我在使用 prisma 编写查询时遇到问题,该查询包含模型关系键上的过滤器。
model Car {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
plate String @unique
place String
bookings Booking[]
@@map("cars")
}
Run Code Online (Sandbox Code Playgroud)
我的预订模型如下:
model Booking{
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
place String
startDate DateTime
endDate DateTime
carId Int
car Car @relation(fields: [carId], references: [id])
@@map("bookings")
}
Run Code Online (Sandbox Code Playgroud)
我无法表达返回每辆车的查询,这些车辆在其预订关系/密钥中遵守 startDate 和 endDate 的给定标准。我将不胜感激任何想法或线索,提前谢谢你。