Skip to content

[JITERA] Implement Review functionality for Books

chi le requested to merge feat/add-reviews-1759145563 into main

Created by: chi-jitera

Overview

This pull request introduces a new Review feature to the existing Book resources. It includes the creation of a Review model, service, controller, and the necessary route to fetch reviews for a specific book.

Changes

  1. models/Review.js:

    • Created a Review model with the following fields:
      • book: ObjectId referencing the Book model (required)
      • reviewer: String to store the reviewer's name (required)
      • rating: Number to store the rating given by the reviewer (required)
      • comment: String for additional comments by the reviewer.
  2. services/reviewService.js:

    • Added a service to fetch reviews based on the book ID. This service interacts with the Review model to retrieve the relevant reviews.
  3. controllers/reviewController.js:

    • Implemented a controller that handles the request to fetch reviews for a specific book. It utilizes the review service to get the data and returns it in JSON format.
  4. routes/bookRoutes.js:

    • Updated the book routes to include a new endpoint GET /books/:id/reviews that maps to the getBookReviews method in the review controller.

This implementation provides a solid foundation for managing reviews associated with books and can be further customized as needed.

Merge request reports