feat: add sorting order

This commit is contained in:
Chen, Tai-Lin committed 2023-12-13 15:05:25 +08:00
1 parent 1b94ae75ca
commit c6733814ba
3 files changed
+39 -7

No files matched your search

+6 -1
View File
@@ -1,3 +1,4 @@
import { Desc } from '../constants.js'
import { userList, userCount } from '../models/users.js'
export async function userListController(req, res) {
@@ -8,7 +9,11 @@ export async function userListController(req, res) {
// const totalUsers = await userCount()
// const maxPages = Math.ceil(totalUsers / itemsPerPage)
const users = await userList({ nextKey, itemsPerPage })
const users = await userList({
nextKey,
itemsPerPage,
order: new Desc(),
})
const newNextKey = users[users.length - 1]?._id
res.render('users', {