mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: change to nextKey in users
This commit is contained in:
1 parent
3e7092dbd6
commit
1b94ae75ca
3 files changed
+20
-14
No files matched your search
@@ -1,20 +1,23 @@
|
||||
import { userList, userCount } from '../models/users.js'
|
||||
|
||||
export async function userListController(req, res) {
|
||||
const pageNumber = req.query.page || 1
|
||||
const { nextKey } = req.query
|
||||
const itemsPerPage = 50
|
||||
|
||||
try {
|
||||
const totalUsers = await userCount()
|
||||
const maxPages = Math.ceil(totalUsers / itemsPerPage)
|
||||
// const totalUsers = await userCount()
|
||||
// const maxPages = Math.ceil(totalUsers / itemsPerPage)
|
||||
|
||||
const users = await userList(pageNumber, itemsPerPage)
|
||||
const users = await userList({ nextKey, itemsPerPage })
|
||||
const newNextKey = users[users.length - 1]?._id
|
||||
|
||||
res.render('users', {
|
||||
users,
|
||||
maxPages: Array.from({ length: maxPages }, (_, index) => index + 1),
|
||||
nextKey: newNextKey,
|
||||
// maxPages: Array.from({ length: maxPages }, (_, index) => index + 1),
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
res.status(500).send('Error fetching user data')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user