From d18f173ef662d0a4c2545300d3b85367bf362983 Mon Sep 17 00:00:00 2001 From: Suvodip Date: Tue, 4 Feb 2025 19:28:07 +0530 Subject: [PATCH] add last attempt function --- src/routes/api/getGameScore.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/routes/api/getGameScore.js b/src/routes/api/getGameScore.js index b6e432d..e5be716 100644 --- a/src/routes/api/getGameScore.js +++ b/src/routes/api/getGameScore.js @@ -18,11 +18,15 @@ async function main() { // const user = await collection.findOne({ childId: 'dsfdfgffgfgeg' }); const { childId, gameName, gameID } = req.body; - const gameData = await collection.findOne({ - childId: childId, - gameName: gameName, - gameID: gameID - }); + const gameData = await collection.findOne( + { + childId: childId, + gameName: gameName, + gameID: gameID + },{ + sort: {_id: -1} + } + ); // console.log('gameData', gameData); if (gameData) { res.json({gameData});