Now dividing total rows by entries/page for actual page count.

This commit is contained in:
BurnyLlama 2021-11-01 19:59:11 +01:00
parent 7fff166c3e
commit 07b4dfe14b

View File

@ -26,14 +26,17 @@ export default function searcher(table, matchField=undefined, matchQuery=undefin
(resolve, reject) => {
const pageCount =
method === "get" ? 0 :
sqlite
.prepare(`
SELECT count(*) FROM ${simpleSanitize(table)}
${matchField ? `WHERE ${simpleSanitize(matchField)} = $matchQuery` : ""}
`)
.get({
matchQuery
})['count(*)']
Math.ceil(
sqlite
.prepare(`
SELECT count(*) FROM ${simpleSanitize(table)}
${matchField ? `WHERE ${simpleSanitize(matchField)} = $matchQuery` : ""}
`)
.get({
matchQuery
})['count(*)']
/ entriesPerPage
)
if (method === "all" && page > pageCount)
reject(`Page number too high! Page count: ${pageCount}`)