From 5f131818d5b61f0ed6309a973f02d4756adf455e Mon Sep 17 00:00:00 2001 From: ROSHAN GARG Date: Wed, 7 Aug 2024 12:42:40 +0530 Subject: [PATCH] sorted the notification by latest --- resources/KYC/KycController.js | 2 ++ resources/Notification/notificationController.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/KYC/KycController.js b/resources/KYC/KycController.js index b0518d2..1b0e8ed 100644 --- a/resources/KYC/KycController.js +++ b/resources/KYC/KycController.js @@ -134,6 +134,7 @@ export const getAllKycRejected = async (req, res) => { // console.log("req came here "); const kycs = await KYC.find({ status: "reject", addedBy: req.user._id }) + .sort({ createdAt: -1 }) .populate("principal_distributer", "name") .populate("addedBy"); // console.log(kycs); @@ -151,6 +152,7 @@ export const getAllKycApproved = async (req, res) => { // Fetch all KYC documents from the database // console.log("req came here "); const kycs = await KYC.find({ status: "approved" }) + .sort({ createdAt: -1 }) .populate("principal_distributer", "name") .populate("addedBy"); // console.log(kycs); diff --git a/resources/Notification/notificationController.js b/resources/Notification/notificationController.js index d8945ed..957b239 100644 --- a/resources/Notification/notificationController.js +++ b/resources/Notification/notificationController.js @@ -8,7 +8,9 @@ export const getNotification = async (req, res) => { } // Fetch notifications for the user - const notifications = await Notification.find({ added_for: req.user._id }); + const notifications = await Notification.find({ + added_for: req.user._id, + }).sort({ createdAt: -1 }); if (notifications && notifications.length > 0) { return res