From 07b4dfe14b87e8fa88e887dfb74ab811efb8ccaf Mon Sep 17 00:00:00 2001 From: BurnyLlama Date: Mon, 1 Nov 2021 19:59:11 +0100 Subject: [PATCH] Now dividing total rows by entries/page for actual page count. --- libs/database/searcher.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libs/database/searcher.js b/libs/database/searcher.js index 3cd391b..59bf4c6 100644 --- a/libs/database/searcher.js +++ b/libs/database/searcher.js @@ -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}`)