Skip to content

Commit

Permalink
populated reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
AVtheking committed Nov 26, 2023
1 parent d661629 commit bf50e9e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions controllers/course_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const courseCtrl = {
const course = await Course.findById(courseId, {
isPublished: true,
isPublished: 0,

__v: 0,
ratings: 0,
})
Expand All @@ -113,6 +113,10 @@ const courseCtrl = {
path: "preview",
select:
"_id videoTitle videoUrl videoDuration videoUrl_144p videoUrl_360p videoUrl_720p",
})
.populate({
path: "reviews.user",
select: "_id username name profileimg",
});

if (!course) {
Expand All @@ -129,7 +133,7 @@ const courseCtrl = {
const wishlistIdIndex = user.wishlist.findIndex((course) =>
course.equals(courseId)
);

if (cartIdIndex != -1) {
in_cart = true;
}
Expand Down Expand Up @@ -216,7 +220,7 @@ const courseCtrl = {
duration: 1,
totalStudents: 1,
category: 1,
weightedRating:1,
weightedRating: 1,
rating: 1,
thumbnail: 1,
createdAt: 1,
Expand Down Expand Up @@ -325,7 +329,7 @@ const courseCtrl = {
.sort({ count: -1 })
.select({ search: 1, _id: 0 })
.limit(5);

res.json({
success: true,
message: "List of popular searches",
Expand Down Expand Up @@ -456,7 +460,7 @@ const courseCtrl = {
thumbnail: 1,
createdAt: 1,
updatedAt: 1,
weightedRating:1,
weightedRating: 1,
createdBy: { _id: 1, username: 1, name: 1 },
},
},
Expand Down

0 comments on commit bf50e9e

Please sign in to comment.