mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: finish errorCommands pagination
This commit is contained in:
1 parent
8c634c8115
commit
bc0055781e
6 files changed
+59
-41
No files matched your search
@@ -1,11 +1,12 @@
|
||||
/* eslint-disable object-shorthand */
|
||||
import { Desc } from '../constants.js'
|
||||
import { Command } from '@linux-odyssey/models'
|
||||
import { errorCommands } from '../models/commands.js'
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export async function commandListController(req, res) {
|
||||
const { nextKey } = req.query
|
||||
const itemsPerPage = 250
|
||||
const itemsPerPage = 100
|
||||
|
||||
try {
|
||||
// const totalCommands = await Command.countDocuments({
|
||||
@@ -20,10 +21,14 @@ export async function commandListController(req, res) {
|
||||
|
||||
// const pageNumber = req.query
|
||||
|
||||
const payload = await errorCommands({ nextKey, itemsPerPage })
|
||||
const payload = await errorCommands({
|
||||
nextKey,
|
||||
itemsPerPage,
|
||||
order: new Desc(),
|
||||
})
|
||||
const newNextKey = payload[payload.length - 1]?._id
|
||||
|
||||
res.render('commands', { payload, nextKey: newNextKey })
|
||||
res.render('commands', { errorCommands: payload, nextKey: newNextKey })
|
||||
} catch (error) {
|
||||
res.status(500).send('Error fetching data')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user