Рефакторинг, небольшие улучшения

This commit is contained in:
Book Pauk
2022-11-28 16:11:54 +07:00
parent a6aa8d8e95
commit af575a87a2
5 changed files with 19 additions and 13 deletions

View File

@@ -625,14 +625,14 @@ class DbSearcher {
const rows = await this.restoreBooks('author', [authorId]);
let authorName = '';
let books = '';
let books = [];
if (rows.length) {
authorName = rows[0].name;
books = rows[0].books;
}
return {author: authorName, books: (books && books.length ? JSON.stringify(books) : '')};
return {author: authorName, books};
} finally {
this.searchFlag--;
}
@@ -659,7 +659,7 @@ class DbSearcher {
where: `return Array.from(@dirtyIndexLR('value', ${db.esc(series)}, ${db.esc(series)}))`
});
let books;
let books = [];
if (rows.length && rows[0].rawResult.length) {
//выборка книг серии
const bookRows = await this.restoreBooks('series', [rows[0].rawResult[0]])
@@ -668,7 +668,7 @@ class DbSearcher {
books = bookRows[0].books;
}
return {books: (books && books.length ? JSON.stringify(books) : '')};
return {books};
} finally {
this.searchFlag--;
}