From e11dc9345a753d43e8ab92638fad392ec546b8bb Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Sun, 15 Jun 2025 09:56:43 +0000
Subject: [PATCH] GS-2160

---
 lib/db.js |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/lib/db.js b/lib/db.js
index 5ae1746..0d319c9 100644
--- a/lib/db.js
+++ b/lib/db.js
@@ -56,7 +56,10 @@
    }
    else {
       const ids = searchLib.search(search)
-      // if (!ids.length) return getUserSearchQuery(offset, limit) // nothing found
+      if (!ids.length) {
+         throw "nothing found"
+         return getUserSearchQuery(offset, limit)
+      } // nothing found
       return `SELECT ${sel}
               FROM ${database}.usr_data AS ud
               WHERE login REGEXP '^[0-9]+$'
@@ -75,14 +78,23 @@
 
    const pool = await poolP
 
-   let userSearchQuery = getUserSearchQuery(offset, limit, search)
-   // console.log(userSearchQuery)
-   const [results, fields] = await pool.query(userSearchQuery)
-   const count = await getUserCount(offset, limit, search)
-   return {
-      total: count,
-      offset, limit,
-      data: results,
+   try {
+      let userSearchQuery = getUserSearchQuery(offset, limit, search)
+      // console.log(userSearchQuery)
+      const [results, fields] = await pool.query(userSearchQuery)
+      const count = await getUserCount(offset, limit, search)
+      return {
+         total: count,
+         offset, limit,
+         data: results,
+      }
+   } catch (ex) {
+      return {
+         total: 0,
+         offset: 0,
+         limit: 0,
+         data: [],
+      }
    }
 }
 

--
Gitblit v1.8.0