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}`)