ilm*_*moi 2 javascript orm prisma
我有 2 张桌子:
model Collection {
id String @id @default(uuid()) @db.Uuid/
floorPrices CollectionFloorPrice[]
}
model CollectionFloorPrice {
id String @id @default(uuid()) @db.Uuid
collection Collection @relation(fields: [collectionId], references: [id])
collectionId String @db.Uuid
}
Run Code Online (Sandbox Code Playgroud)
如何查询仅包含行的集合CollectionFloorPrice?在 SQL 中,这将是一个简单的 JOIN。
这不起作用:
return await this.prisma.collection.findMany({
where: {
floorPrices: {
exists: true,
},
},
});
Run Code Online (Sandbox Code Playgroud)
小智 5
prisma.collection.findMany({
where: { floorPrices: { some: {} } }
})
Run Code Online (Sandbox Code Playgroud)