P
Prisma•7mo ago
roobr

orderBy on a relation include

Hello, I am hoping for some assistance with the best way to handle my query and see what is possible.
const items = await prisma.items.findMany({
include: {
item_categories_item_categories_item_idTocategories: {
include: {
categories_item_categories_category_idTocategories: {
select: {
id: true,
name: true,
},
orderBy: {
list_order: 'asc',
},
},
},
},
item_subcategory_item_subcategory_item_idTosubcategories: {
include: {
subcategories_item_subcategory_subcat_idTosubcategories: {
select: {
id: true,
name: true,
main_category: true,
},
},
},
},
},
const items = await prisma.items.findMany({
include: {
item_categories_item_categories_item_idTocategories: {
include: {
categories_item_categories_category_idTocategories: {
select: {
id: true,
name: true,
},
orderBy: {
list_order: 'asc',
},
},
},
},
item_subcategory_item_subcategory_item_idTosubcategories: {
include: {
subcategories_item_subcategory_subcat_idTosubcategories: {
select: {
id: true,
name: true,
main_category: true,
},
},
},
},
},
2 Replies
Nurul
Nurul•7mo ago
Hey 👋 Could you elaborate on what you are trying to achieve?
roobr
roobrOP•7mo ago
Hello Nurul, I would like to select a relationship and have the results ordered by a column list_order using the orderBy function. It seems you cannot use the orderby function on a include relationship
Want results from more Discord servers?
Add your server