implemented pagination

This commit is contained in:
2024-01-10 15:53:46 +01:00
parent c0e4c364d4
commit ccb628aadb
4 changed files with 191 additions and 22 deletions

View File

@@ -76,7 +76,13 @@ export const fetchAvailableYears = withUser(async (user:AuthenticatedUser) => {
const dbClient = await getDbClient();
// query mnogodb for all `yearMonth` values
const yearMonths = await dbClient.collection<BillingLocation>("lokacije").distinct("yearMonth.year", { userId });
const years = await dbClient.collection<BillingLocation>("lokacije")
.distinct("yearMonth.year", { userId })
return(yearMonths);
// sort the years in descending order
const sortedYears = years.sort((a, b) => b - a);
console.log("sortedYears", sortedYears);
return(sortedYears);
})