Работа над проектом
This commit is contained in:
@@ -82,7 +82,7 @@ class DbCreator {
|
||||
const authorTmpId = authorMap.get(value);
|
||||
authorRec = authorArr[authorTmpId];
|
||||
} else {
|
||||
authorRec = {tmpId: authorArr.length, author: a, value, bookId: []};
|
||||
authorRec = {tmpId: authorArr.length, author: a, value, bookCount: 0, bookDelCount: 0, bookId: []};
|
||||
authorArr.push(authorRec);
|
||||
authorMap.set(value, authorRec.tmpId);
|
||||
|
||||
@@ -94,6 +94,13 @@ class DbCreator {
|
||||
if (a[0].toUpperCase() === a[0])
|
||||
authorRec.author = a;
|
||||
|
||||
//счетчики
|
||||
if (!rec.del) {
|
||||
authorRec.bookCount++;
|
||||
} else {
|
||||
authorRec.bookDelCount++;
|
||||
}
|
||||
|
||||
//ссылки на книги
|
||||
authorRec.bookId.push(id);
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ class DbSearcher {
|
||||
//выборка найденных авторов
|
||||
let result = await db.select({
|
||||
table: 'author',
|
||||
map: `(r) => ({id: r.id, author: r.author})`,
|
||||
map: `(r) => ({id: r.id, author: r.author, bookCount: r.bookCount, bookDelCount: r.bookDelCount})`,
|
||||
where: `@@id(${db.esc(authorIds.slice(offset, offset + limit))})`
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user