'Prisma ORM : orderBy on table of relation
We are trying into a prisma.order.findFirst to orderBy date asc the activitys of activityOrder which have an order table statut attributes ='PENDING' and a order table attributes tableId=req.params.id,
There is the code below of our prisma.order.findFirst :
const ActivityOfPendingOrder = await prisma.order.findFirst({
where: {
tableId: req.params.id,
statut: 'PENDING',
},
include: {
ActivityOrder: {
select: {
activity: {
orderBy:{
date: 'asc'
},
select: {
description: true,
date: true,
img: true,
subImg: true,
author: {
select: {
firstName: true,
lastName: true
}
}
}
}
},
},
},
})
Before adding OrderBy we never had problem with the code of ActivityOfPendingOrder.
We followed the documentation about filtering-and-sorting with prisma : https://www.prisma.io/docs/concepts/components/prisma-client/filtering-and-sorting.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
