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
alexblokh3w ago
No description
alexblokh
alexblokh3w ago
that's essentially how it's done under the hood
alexblokh
alexblokh3w ago
No description
alexblokh
alexblokh3w ago
that's how our own operat would look like, we will add one in ORM cc: @TSK_SMILEY
alexblokh
alexblokh3w 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_SMILEYOP3w ago
okay, thank you
Want results from more Discord servers?
Add your server