Compare commits
2 Commits
4145dafb7d
...
a8b0374d5e
Author | SHA1 | Date | |
---|---|---|---|
a8b0374d5e | |||
90dbadac24 |
@ -14,15 +14,14 @@ async function get(req: Request, res: Response) {
|
|||||||
const takeSize = 25; // Amount of times per page
|
const takeSize = 25; // Amount of times per page
|
||||||
const pageSize = Math.ceil(itemCount / takeSize); // Amount of pages, always round up
|
const pageSize = Math.ceil(itemCount / takeSize); // Amount of pages, always round up
|
||||||
|
|
||||||
// If page is less then 1 or more then the max page size redirect to first or last page
|
// If page is less then 1 or more then the max page size redirect to first or last page. If itemCount is 0 do not redirect.
|
||||||
if (page < 1) {
|
if (page < 1) {
|
||||||
res.redirect('?page=1');
|
res.redirect('?page=1');
|
||||||
return;
|
return;
|
||||||
} else if (page > pageSize) {
|
} else if (page > pageSize && itemCount !== 0) {
|
||||||
res.redirect('?page=' + pageSize);
|
res.redirect('?page=' + pageSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prisma.item
|
prisma.item
|
||||||
.findMany({ skip: (page - 1) * takeSize, take: takeSize }) // Skip the amount of items per page times the page number minus 1; skip has to be (page-1)*takeSize because skip is 0 indexed
|
.findMany({ skip: (page - 1) * takeSize, take: takeSize }) // Skip the amount of items per page times the page number minus 1; skip has to be (page-1)*takeSize because skip is 0 indexed
|
||||||
.then((items) => {
|
.then((items) => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const currentToasts = [];
|
currentToasts = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic function to create a new toast
|
* Generic function to create a new toast
|
||||||
|
Loading…
Reference in New Issue
Block a user