refactor: add Pagination class

This commit is contained in:
Chen, Tai-Lin committed 2023-12-21 17:09:20 +08:00
1 parent 19cd10ab7b
commit 68db16419d
9 files changed
+99 -89

No files matched your search

+3 -7
View File
@@ -1,16 +1,12 @@
import { Desc } from '../constants.js'
import { userList, userCount } from '../models/users.js'
import { Desc } from '../models/pagination.js'
import { userList } from '../models/users.js'
export async function userListController(req, res) {
const { nextKey } = req.query
const itemsPerPage = 50
try {
const users = await userList({
nextKey,
itemsPerPage,
order: new Desc(),
})
const users = await userList(new Desc(itemsPerPage, nextKey))
const newNextKey = users[users.length - 1]?._id
res.render('users', { users, nextKey: newNextKey })