NULLS LAST in orderBy

I am trying to create a query and the only way i have been able to order by with nulls last is this:
const rows = await db
.select().from(s.webshop)
.leftJoin(s.searchRank, eq(s.webshop.id, s.searchRank.webshopId))
.where(and(
eq(s.webshop.enabled, true),
eq(s.webshop.disableSeoPage, false).if(onlyFetchIfSeoAllowed)
))
.orderBy(desc(s.searchRank.usage), sql`nulls last`)
const rows = await db
.select().from(s.webshop)
.leftJoin(s.searchRank, eq(s.webshop.id, s.searchRank.webshopId))
.where(and(
eq(s.webshop.enabled, true),
eq(s.webshop.disableSeoPage, false).if(onlyFetchIfSeoAllowed)
))
.orderBy(desc(s.searchRank.usage), sql`nulls last`)
so my question is: is there a way to do this without using an escape hatch?
6 Replies
alexblokh
alexblokh2mo ago
No description
alexblokh
alexblokh2mo ago
that's essentially how it's done under the hood
alexblokh
alexblokh2mo ago
No description
alexblokh
alexblokh2mo ago
that's how our own operat would look like, we will add one in ORM cc: @TSK_SMILEY
alexblokh
alexblokh2mo ago
Drizzle ORM - DrizzleORM v0.31.0 release
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
TSK_SMILEY
TSK_SMILEYOP2mo ago
okay, thank you
Want results from more Discord servers?
Add your server