0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 15:22:41 +00:00

total brews found

This commit is contained in:
Víctor Losada Hernández
2024-02-15 01:26:54 +01:00
parent 46262c56db
commit 3427fa1e94
2 changed files with 9 additions and 6 deletions

View File

@@ -34,12 +34,12 @@ const archive = {
// No published documents found with the given title
return res.status(404).json({ error: 'Published documents not found' });
}
const totalDocuments = await HomebrewModel.countDocuments(titleQuery, projection);
const totalBrews = await HomebrewModel.countDocuments(titleQuery, projection);
const totalPages = Math.ceil(totalDocuments / pageSize);
console.log('Total brews: ', totalDocuments);
const totalPages = Math.ceil(totalBrews / pageSize);
console.log('Total brews: ', totalBrews);
console.log('Total pages: ', totalPages);
return res.json({ brews, page, totalPages });
return res.json({ brews, page, totalPages, totalBrews});
} catch (error) {
console.error(error);
return res.status(500).json({ error: 'Internal Server Error' });