DSCKGEC/Libraryly

Adding Review Books logic

Closed this issue ยท 3 comments

A new model-route-controller-service is to be added for CRUD operations of Book Reviews.
The review model should include the following:

  1. author - the review author / user who reviews the book (as reference)
  2. rating - numerical rating
  3. comment - textual remarks
  4. book - book being reviewed (as reference)

@saggy2001

In the book model, add a new property named rating which will be of type: Number with default value as 4.
Now, whenever a new rating for a book is added, this value from that book model will be updated with the new average.

Example:
We create a new book - let's say X. Now it will have a default rating as 4.
Let's say a user reviews the book with rating 3. As soon as this rating endpoint is hit, we will update X's rating with 4 + 3 / 2 = 3.5

Assign me this issue I will do it

@saggy2001
Update:-
We create a new book, whose id is, let's say, X. The default rating would be 0. Now, as soon as a review is added/updated, we will update the rating field of X by calling a function, whose work is to find all ratings of X , averaging and returning the value.