mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 11:10:11 +08:00
refactor: add Pagination class
This commit is contained in:
1 parent
19cd10ab7b
commit
68db16419d
9 files changed
+99
-89
No files matched your search
@@ -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 })
|
||||
|
||||
Reference in new issue
Block a user