Skip to content

Commit

Permalink
fix sorting with nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
cmintey committed Sep 6, 2024
1 parent c33c832 commit 6b91f6a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/routes/wishlists/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ export const load: PageServerLoad = async ({ locals, params, url, depends }) =>

const [wishlistItems, listOwner] = await Promise.all([wishlistItemsQuery, listOwnerQuery]);

if (sort === "price" && direction === "asc") {
// need to re-sort when descending since Prisma can't order with nulls last
wishlistItems.sort((a, b) => (a.itemPrice?.value ?? Infinity) - (b.itemPrice?.value ?? Infinity));
}

depends("data:items");
return {
user: locals.user,
Expand Down

0 comments on commit 6b91f6a

Please sign in to comment.