From b27395697b4e4851385f20cb7ae9c8470aff3c2c Mon Sep 17 00:00:00 2001 From: ak Date: Thu, 28 Sep 2023 14:28:18 -0700 Subject: [PATCH] fixed sorting function --- controllers/post.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/controllers/post.js b/controllers/post.js index 840c55e..849bfdd 100644 --- a/controllers/post.js +++ b/controllers/post.js @@ -97,8 +97,7 @@ exports.get = asyncHandler(async (req, res, next) => { const dbPost = await Post.findById(req.params.postID).lean().exec(); const comments = await Comment.find({ post: dbPost._id }) .sort({ - field: "date", - desc, + date: -1, }) .lean() .exec();