Sort nulls at the end even in desc order

This commit is contained in:
Zoe Roux 2025-01-10 00:35:52 +01:00
parent c71650d386
commit 3547799079
No known key found for this signature in database

View File

@ -177,7 +177,7 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
.innerJoin(transQ, eq(shows.pk, transQ.pk)) .innerJoin(transQ, eq(shows.pk, transQ.pk))
.where(and(filter, keysetPaginate({ table: shows, after, sort }))) .where(and(filter, keysetPaginate({ table: shows, after, sort })))
.orderBy( .orderBy(
...sort.map((x) => (x.desc ? desc(shows[x.key]) : shows[x.key])), ...sort.map((x) => (x.desc ? sql`${shows[x.key]} desc nulls last` : shows[x.key])),
shows.pk, shows.pk,
) )
.limit(limit); .limit(limit);