Fix PocketBase query error by sorting by date instead of created
All checks were successful
Deploy / deploy (push) Successful in 2m28s
All checks were successful
Deploy / deploy (push) Successful in 2m28s
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<DailyLog>(
|
||||
`user="${user.id}" && date>="${today}" && date<"${tomorrow}"`,
|
||||
{ sort: "-created" },
|
||||
{ sort: "-date" },
|
||||
);
|
||||
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user