From 8cbf254f3839a2321e2810eacf2b6bacf45a26f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Tue, 9 Jan 2024 16:25:23 +0100 Subject: [PATCH] fixed result sorting --- app/lib/actions/locationActions.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/lib/actions/locationActions.ts b/app/lib/actions/locationActions.ts index cd704c2..be93b0d 100644 --- a/app/lib/actions/locationActions.ts +++ b/app/lib/actions/locationActions.ts @@ -98,7 +98,11 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, pageIx: // fetch `pageSize` locations for the given page index const locations = await dbClient.collection("lokacije") .find({ userId }) - .sort({ yearMonth: -1, name: 1 }) + .sort({ + "yearMonth.year": -1, + "yearMonth.month": -1, + name: 1, + }) .skip(pageIx * pageSize) .limit(pageSize) .toArray();