Browse Source

fix get total link count query where greater than or smaller than queries didn't work

Pouria Ezzati 1 year ago
parent
commit
27b73a4b1d
1 changed files with 6 additions and 2 deletions
  1. 6 2
      server/queries/link.queries.js

+ 6 - 2
server/queries/link.queries.js

@@ -43,9 +43,13 @@ function normalizeMatch(match) {
 };
 
 async function total(match, params) {
-  const query = knex("links")
-    .where(normalizeMatch(match));
+  const normalizedMatch = normalizeMatch(match);
+  const query = knex("links");
   
+  Object.entries(normalizedMatch).forEach(([key, value]) => {
+    query.andWhere(key, ...(Array.isArray(value) ? value : [value]));
+  });
+
   if (params?.search) {
     query.andWhereRaw(
       "concat_ws(' ', description, links.address, target, domains.address) ILIKE '%' || ? || '%'",