Recent and Oldest: These cases sort by the createdAt
field. createdAt: -1
sorts in descending order (newest first), while createdAt: 1
sorts in ascending order (oldest first).
Most Commented: This case sorts by commentsCount
in descending order (commentsCount: -1
), which means posts with the highest number of comments appear first.
Most Liked: This case sorts by likesCount
in descending order (likesCount: -1
), so posts with the highest number of likes are listed first.
Error Handling: Throws an error if the filter type is invalid or if there's an issue querying the
frist comment