From f49f5104591c501eb4d00f8df6cdcbfefbea14d8 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 16 Feb 2021 23:07:40 +0100 Subject: [PATCH] fixes in "other notes with relation..." --- src/routes/api/search.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/routes/api/search.js b/src/routes/api/search.js index f016cbf82..b15e13ee8 100644 --- a/src/routes/api/search.js +++ b/src/routes/api/search.js @@ -232,7 +232,9 @@ function getRelatedNotes(req) { const results = []; - for (const record of matchingNameAndValue.concat(matchingName)) { + const allResults = matchingNameAndValue.concat(matchingName); + + for (const record of allResults) { if (results.length >= 20) { break; } @@ -245,7 +247,7 @@ function getRelatedNotes(req) { } return { - count: matchingName.length, + count: allResults.length, results }; } @@ -266,6 +268,10 @@ function formatAttrForSearch(attr, searchWithValue) { searchStr += attr.name; if (searchWithValue && attr.value) { + if (attr.type === 'relation') { + searchStr += ".noteId"; + } + searchStr += '='; searchStr += formatValue(attr.value); }