Адаптация к jembadb 5.0

This commit is contained in:
Book Pauk
2022-10-21 18:21:30 +07:00
parent 87d418a32a
commit 46829a9b08

View File

@@ -44,7 +44,7 @@ class DbSearcher {
where = `@@indexIter('value', (v) => { where = `@@indexIter('value', (v) => {
const enru = new Set(${db.esc(enruArr)}); const enru = new Set(${db.esc(enruArr)});
return !v || (!enru.has(v[0].toLowerCase()) && v.indexOf(${db.esc(a)}) >= 0); return !v || (!enru.has(v[0].toLowerCase()) && v.indexOf(${db.esc(a)}) >= 0);
});`; })`;
} else { } else {
where = `@@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`; where = `@@dirtyIndexLR('value', ${db.esc(a)}, ${db.esc(a + maxUtf8Char)})`;
} }
@@ -64,22 +64,22 @@ class DbSearcher {
const authorRows = await db.select({ const authorRows = await db.select({
table: 'author', table: 'author',
dirtyIdsOnly: true, rawResult: true,
where where: `return Array.from(${where.substring(1)})`,
}); });
for (const row of authorRows) if (authorRows.length)
authorIds.push(row.id); authorIds = authorRows[0].rawResult;
} else {//все авторы } else {//все авторы
if (!this.searchCache.authorIdsAll) { if (!this.searchCache.authorIdsAll) {
const authorRows = await db.select({ const authorRows = await db.select({
table: 'author', table: 'author',
dirtyIdsOnly: true, rawResult: true,
where: `return Array.from(@all())`,
}); });
for (const row of authorRows) { if (authorRows.length)
authorIds.push(row.id); authorIds = authorRows[0].rawResult;
}
this.searchCache.authorIdsAll = authorIds; this.searchCache.authorIdsAll = authorIds;
} else {//оптимизация } else {//оптимизация