Saim Akhtar
01/07/2022, 4:03 PMmodel Item {
id Int
itemName String @map("item_name")
variants Variants[]
}
model Variants {
id Int
unitPrice Decimal @map("unit_price")
item Item
}
NOW I want to sort items by minimum price of any of its variant
Is there a way I can achieve it via Prisma client, without using raw query to get my mapped fields in schema
P.S: Prisma doesn’t provide option of other fields for nested relation apart from _countMaciek K
01/07/2022, 5:31 PMawait prisma.item.findMany({
orderBy: {
variants: {
unitPrice: 'asc'
}
}
})
Saim Akhtar
01/07/2022, 5:36 PMMaciek K
01/07/2022, 5:51 PMMaciek K
01/07/2022, 5:52 PMMaciek K
01/07/2022, 5:56 PMawait prisma.variants.findMany({
where: {
itemId: yourItemid
},
orderBy: {
unitPrice: 'asc'
}
})
Saim Akhtar
01/10/2022, 8:18 AMSaim Akhtar
01/10/2022, 8:19 AM