Skip to content

Commit

Permalink
#84 backend add Comment get Product id
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Oct 18, 2022
1 parent bead1e3 commit d7e8c7f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const {
getallProductUserDetail,
} = require("./getproduct.service");
const Products = require("../../../models/ProductModel");
const {
handleGetCommentProductId,
} = require("../review.service/review.service");
module.exports = {
HandleGetProduct: async () => {
const products = await getallProductUser();
Expand All @@ -26,7 +29,10 @@ module.exports = {
return {
status: 200,
success: true,
element: product_detail,
element: {
product_detail,
comment: await handleGetCommentProductId(product_id),
},
};
},
handleAddToCart: async ({ user_id, product_id, quantity }) => {
Expand Down
11 changes: 11 additions & 0 deletions backend/src/v1/user_api/services/review.service/review.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,15 @@ module.exports = {
},
};
},
handleGetCommentProductId: async (product_id) => {
return await Products.findById(product_id)
.populate({
path: "reviews",
populate: {
path: "user",
select: { name: 1, email: 1, image: 1 },
},
})
.select("reviews");
},
};
Binary file modified dump.rdb
Binary file not shown.

0 comments on commit d7e8c7f

Please sign in to comment.