Multiple orderby in single relation

Hi Guys I want to know how to do multiple sort like for example there is 2 column called priority and created_at. If priority is filled or not null or not = 0 it will use the priority If priority is not filled or null or = 0 it will use created_at here is my code
const result = await db.query.property.findFirst({
with: {
content: {
with: {
photos: {
orderBy: (photos, { desc }) => [desc(photos.priority)]},
facilities: true
}
},
room_type: {
with: {
rate_plans: true
}
},
},
where: (property, { eq }) => eq(property.slug, slug),
});
const result = await db.query.property.findFirst({
with: {
content: {
with: {
photos: {
orderBy: (photos, { desc }) => [desc(photos.priority)]},
facilities: true
}
},
room_type: {
with: {
rate_plans: true
}
},
},
where: (property, { eq }) => eq(property.slug, slug),
});
i only able to do one
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server