From 317f0cfb4d1a047b649b30242f5dd4edbfde07c6 Mon Sep 17 00:00:00 2001 From: Ethan Ho Date: Thu, 1 Feb 2024 15:22:44 -0800 Subject: [PATCH] Modified /catalog get to return data and amount of events Co-authored-by: Maithy Le --- routes/catalog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routes/catalog.js b/routes/catalog.js index 77ab008..552e927 100644 --- a/routes/catalog.js +++ b/routes/catalog.js @@ -13,7 +13,8 @@ catalogRouter.get('/', async (req, res) => { const offset = (page - 1) * limit; const allInfo = await db.query(`SELECT * from catalog LIMIT $1 OFFSET $2;`, [limit, offset]); - res.status(200).json(keysToCamel(allInfo)); + const eventCount = await db.query(`SELECT COUNT(DISTINCT id) from catalog;`); + res.status(200).json(keysToCamel({ events: allInfo, count: eventCount })); } catch (err) { res.status(500).send(err.message); }