Skip to content

Commit

Permalink
Merge pull request #62 from moevm/server/add-info-for-books-in-search
Browse files Browse the repository at this point in the history
server: add info for books in search
  • Loading branch information
TatyanaYarusova authored Dec 12, 2024
2 parents 0edea7d + b71c5b3 commit 3fcbd22
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/src/controllers/booksController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,21 @@ export const getBooks = async (req: Request, res: Response) => {
name: "$book.name",
year: "$book.year",
authorName: "$authorName"
}
},
totalQuotes: { $sum: 1 },
uniqueHeroes: { $addToSet: "$hero" }
}
},
{
$project: {
_id: 0,
name: "$_id.name",
year: "$_id.year",
authorName: "$_id.authorName"
authorName: "$_id.authorName",
totalQuotes: 1,
totalHeroes: { $size: "$uniqueHeroes" }
}
}
},
]);

const totalBooks = books.length;
Expand Down

0 comments on commit 3fcbd22

Please sign in to comment.