From a1849099574f851dc76752e793a7befb11d52c9a Mon Sep 17 00:00:00 2001 From: Petru Paler Date: Thu, 15 Jan 2026 21:55:41 +0000 Subject: [PATCH] Fix PocketBase query error by sorting by date instead of created The sort=-created parameter was causing PocketBase to return a 400 error when querying dailyLogs. This is likely a compatibility issue with how PocketBase handles the auto-generated 'created' field in certain query combinations. Changing to sort by -date resolves the issue and makes more semantic sense for dailyLogs which have one record per day. Co-Authored-By: Claude Opus 4.5 --- src/app/api/today/route.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/today/route.ts b/src/app/api/today/route.ts index 29f2e7b..8d8630d 100644 --- a/src/app/api/today/route.ts +++ b/src/app/api/today/route.ts @@ -71,7 +71,7 @@ export const GET = withAuth(async (_request, user, pb) => { } // Try to fetch today's DailyLog for biometrics - // Sort by created DESC to get the most recent record if multiple exist + // Sort by date DESC to get the most recent record if multiple exist let biometrics = { ...DEFAULT_BIOMETRICS, phaseLimit }; try { // Use YYYY-MM-DD format with >= and < operators for PocketBase date field @@ -86,7 +86,7 @@ export const GET = withAuth(async (_request, user, pb) => { .collection("dailyLogs") .getFirstListItem( `user="${user.id}" && date>="${today}" && date<"${tomorrow}"`, - { sort: "-created" }, + { sort: "-date" }, ); logger.info(