From 46829a9b08af138e73adfea8ddecd42f540f89c0 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 21 Oct 2022 18:21:30 +0700 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=B4=D0=B0=D0=BF=D1=82=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BA=20jembadb=205.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/DbSearcher.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/core/DbSearcher.js b/server/core/DbSearcher.js index 589323b..ff8ae7c 100644 --- a/server/core/DbSearcher.js +++ b/server/core/DbSearcher.js @@ -44,7 +44,7 @@ class DbSearcher { where = `@@indexIter('value', (v) => { const enru = new Set(${db.esc(enruArr)}); return !v || (!enru.has(v[0].toLowerCase()) && v.indexOf(${db.esc(a)}) >= 0); - });`; + })`; } else { where = `@@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`; } @@ -64,22 +64,22 @@ class DbSearcher { const authorRows = await db.select({ table: 'author', - dirtyIdsOnly: true, - where + rawResult: true, + where: `return Array.from(${where.substring(1)})`, }); - for (const row of authorRows) - authorIds.push(row.id); + if (authorRows.length) + authorIds = authorRows[0].rawResult; } else {//все авторы if (!this.searchCache.authorIdsAll) { const authorRows = await db.select({ table: 'author', - dirtyIdsOnly: true, + rawResult: true, + where: `return Array.from(@all())`, }); - for (const row of authorRows) { - authorIds.push(row.id); - } + if (authorRows.length) + authorIds = authorRows[0].rawResult; this.searchCache.authorIdsAll = authorIds; } else {//оптимизация @@ -407,7 +407,7 @@ class DbSearcher { } this.searchCache = null; - + if (this.timer) { clearTimeout(this.timer); this.timer = null;