TSK_SMILEY
TSK_SMILEY
DTDrizzle Team
Created by TSK_SMILEY on 10/15/2024 in #help
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?
8 replies