From 67f54fbfaf850883e50e6c2337383f33e65932c8 Mon Sep 17 00:00:00 2001 From: Matteo Tagliatti Date: Fri, 17 Nov 2023 16:02:38 +0100 Subject: [PATCH] Fix book order in GET request --- src/routes/api/books/+server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/api/books/+server.ts b/src/routes/api/books/+server.ts index 20f1d5d..ab00346 100644 --- a/src/routes/api/books/+server.ts +++ b/src/routes/api/books/+server.ts @@ -5,6 +5,7 @@ export const GET: RequestHandler = async ({ url, locals: { supabase } }) => { const username = String(url.searchParams.get("username")); const status = String(url.searchParams.get("status")); const limit = Number(url.searchParams.get("limit") || 10); + const order = String(url.searchParams.get("order") || "updated_at"); if (!username) { throw error(400, "username is required"); @@ -29,7 +30,7 @@ export const GET: RequestHandler = async ({ url, locals: { supabase } }) => { .select() .eq("owner", user.id) .eq("status", status) - .order("finished", { ascending: false }) + .order(order, { ascending: false }) .limit(limit); if (books_error) throw error;