From 8c854764eacbdfd5940408aae7dfa247a296d860 Mon Sep 17 00:00:00 2001 From: Toly Date: Sun, 2 Feb 2025 12:11:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Update=20today=20api.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/word.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/routes/word.js b/routes/word.js index 7e8e939..634aa8f 100644 --- a/routes/word.js +++ b/routes/word.js @@ -44,13 +44,10 @@ router.get("/thisweek", async function (req, res, next) { router.get("/today", async function (req, res, next) { const startOfDay = moment().startOf("day").toDate(); const endOfDay = moment().endOf("day").toDate(); - const t = await wordModel.countDocuments({ - createdAt: { - $gte: startOfDay, - $lt: endOfDay, - }, - }); - res.json(generateResponse({ count: t })); + const w = await wordModel + .find({ createdAt: { $gte: startOfDay, $lt: endOfDay } }) + .exec(); + res.json(generateResponse({ count: w.length, wordList: w })); }); router.get("/:id", async function (req, res, next) {