backend
    Preparing search index...
    Index

    Constructors

    Methods

    • Parameters

      • createCommentDto: CreateCommentDto

        An object containing the text of the comment to be created.

      • userId: string

        The ID of the user creating the comment. This is typically extracted from the session or authentication token.

      • bookId: string

        The ID of the book for which the comment is being created.

      Returns Promise<
          {
              user: {
                  biggerProfilePic: string
                  | null;
                  nickname: string | null;
                  smallerProfilePic: string | null;
              };
          } & {
              bookId: string;
              createdAt: Date;
              id: string;
              text: string;
              userId: string;
          },
      >

      A promise resolving to the created comment.

      Creates a new comment for a given book ID. The comment is associated with the user who created it, and the text of the comment is provided in the request body. This method is used to allow users to share their thoughts and opinions about a book by adding comments.

      InternalServerErrorException - If there is an error while creating the comment in the database.

      NotFoundException - If the specified book does not exist in the database.

      This method also updates the book statistics by incrementing the review count for the associated book. If the specified book does not exist, a NotFoundException is thrown. If there is an error while creating the comment, an InternalServerErrorException is thrown.

    • Parameters

      • commentId: string

        The ID of the comment for which to create a like.

      • userId: string

        The ID of the user creating the like.

      Returns Promise<{ commentId: string; userId: string }>

      A promise resolving to the created like.

      Creates a new like for an existing comment identified by its ID. This method allows users to express their appreciation for a comment.

      NotFoundException - If the specified comment does not exist in the database.

      BadRequestException - If the like already exists.

      InternalServerErrorException - If there is an error while creating the like in the database.

    • Parameters

      • commentId: string

        The ID of the comment to be deleted.

      • userId: string

      Returns Promise<
          {
              bookId: string;
              createdAt: Date;
              id: string;
              text: string;
              userId: string;
          },
      >

      • A promise resolving to the deleted comment.

      Deletes an existing comment identified by its ID. This method allows users to remove their comments if they no longer wish to have them displayed, or if they want to delete inappropriate content.

      NotFoundException - If the specified comment does not exist in the database.

      InternalServerErrorException - If there is an error while deleting the comment from the database.

      ForbiddenException - If the user is not the owner of the comment.

      This method also updates the book statistics by decrementing the review count for the associated book. If the specified comment does not exist, a NotFoundException is thrown. If the user is not the owner of the comment, a ForbiddenException is thrown. If there is an error while deleting the comment, an InternalServerErrorException is thrown.

    • Parameters

      • commentId: string

        The ID of the comment for which to delete the like.

      • userId: string

        The ID of the user deleting the like.

      Returns Promise<{ commentId: string; userId: string }>

      A promise resolving to the deleted like.

      Deletes an existing like for a comment identified by its ID. This method allows users to remove their like from a comment if they no longer wish to express their appreciation for it.

      NotFoundException - If the specified like does not exist in the database.

      InternalServerErrorException - If there is an error while deleting the like from the database.

    • Parameters

      • bookId: string

        The ID of the book for which to retrieve comments. *

      Returns Promise<
          (
              {
                  user: {
                      email: string;
                      nickname: string
                      | null;
                      smallerProfilePic: string | null;
                  };
              } & {
                  bookId: string;
                  createdAt: Date;
                  id: string;
                  text: string;
                  userId: string;
              }
          )[],
      >

      A list of comments associated with the given book ID. Each comment includes the text of the comment, the creation date, and user information (nickname, email, smaller profile picture).

      Retrieves a list of comments associated with a given book ID. The comments are ordered by creation date in descending order and include user information such as nickname, email, and smaller profile picture. This method is used to display the comments section for a book, allowing users to see what others have said about the book.

      InternalServerErrorException - If there is an error while retrieving comments from the database.

    • Parameters

      • userId: string

        The ID of the user for whom to retrieve the comment history.

      Returns Promise<
          (
              {
                  _count: { votes: number };
                  book: {
                      approveStatus: boolean;
                      authorId: string | null;
                      biggerCoverPic: string;
                      biggerCoverPicKey: string | null;
                      createdAt: Date;
                      description: string;
                      googleBookId: string | null;
                      id: string;
                      latestPublicationYear: number | null;
                      openLibraryId: string | null;
                      originalPublicationYear: number | null;
                      originalPublisher: string | null;
                      pageNumber: number | null;
                      smallerCoverPic: string;
                      smallerCoverPicKey: string | null;
                      title: string;
                      updatedAt: Date;
                  };
              } & {
                  bookId: string;
                  createdAt: Date;
                  id: string;
                  text: string;
                  userId: string;
              }
          )[],
      >

      A list of comments made by the specified user. Each comment includes the text of the comment, the creation date, information about the associated book, and the number of likes for the comment.

      Retrieves a list of comments made by a specific user. The comments are ordered by creation date in descending order and include information about the associated book and the number of likes for each comment. This method is used to display a user's comment history, allowing them to see all the comments they have made across different books.

      If there is an error while retrieving the comment history from the database, an InternalServerErrorException is thrown.

      InternalServerErrorException - If there is an error while retrieving the comment history from the database.

    • Parameters

      • bookId: string

        The ID of the book that the user has read.

      • userId: string

        The ID of the user who has read the book.

      Returns Promise<{ addedAt: Date; bookId: string; id: string; userId: string }>

      A promise resolving to the created record indicating that the user has read the book.

      Creates a record indicating that a user has read a specific book. This method is used to track which books a user has read, allowing for features such as personalized recommendations and reading history.

      If the user has already marked the book as read, this method will not create a duplicate record and will not increment the readers count for the book. If the specified book does not exist, a NotFoundException is thrown. If there is an error while creating the record, an InternalServerErrorException is thrown.

      NotFoundException - If the specified book does not exist in the database.

      InternalServerErrorException - If there is an error while creating the record in the database.

    • Parameters

      • authorId: string

        The ID of the author that the user likes.

      • userId: string

        The ID of the user who likes the author.

      Returns Promise<{ authorId: string; userId: string }>

      A promise resolving to the created record indicating that the user likes the author.

      Creates a record indicating that a user likes a specific author. This method is used to track which authors a user has liked, allowing for features such as personalized recommendations and favorite author lists.

      If the user has already liked the author, this method will not create a duplicate record. If the specified author does not exist, a NotFoundException is thrown. If there is an error while creating the record, an InternalServerErrorException is thrown.

      InternalServerErrorException - If there is an error while creating the record in the database.

    • Parameters

      • bookId: string

        The ID of the book that the user likes.

      • userId: string

        The ID of the user who likes the book.

      Returns Promise<{ bookId: string; userId: string }>

      A promise resolving to the created record indicating that the user likes the book.

      Creates a record indicating that a user likes a specific book. This method is used to track which books a user has liked, allowing for features such as personalized recommendations and favorite book lists.

      If the user has already liked the book, this method will not create a duplicate record and will not increment the wantToReadCount for the book. If the specified book does not exist, a NotFoundException is thrown. If there is an error while creating the record, an InternalServerErrorException is thrown.

      InternalServerErrorException - If there is an error while creating the record in the database.

    • Parameters

      • bookId: string

        The ID of the book to be rated.

      • userId: string

        The ID of the user who is rating the book.

      • createRatingDto: CreateRatingDto

        The DTO containing the rating score.

      Returns Promise<{ bookId: string; createdAt: Date; score: number; userId: string }>

      A promise resolving to the created rating record.

      Creates a rating record for a specific book by a user. This method is used to allow users to rate books, which helps in generating personalized recommendations and maintaining book popularity metrics.

      If the user has already rated the book, this method will throw a BadRequestException. If the specified book does not exist, a NotFoundException is thrown. If there is an error while creating the rating record, an InternalServerErrorException is thrown.

      InternalServerErrorException - If there is an error while creating the rating record in the database.

    • Parameters

      • authorId: string

        The ID of the author that the user wants to unlike.

      • userId: string

        The ID of the user who wants to unlike the author.

      Returns Promise<{ authorId: string; userId: string }>

      A promise resolving to the deleted record indicating that the user no longer likes the author.

      Deletes a record indicating that a user likes a specific author. This method is used to allow users to remove their like from an author if they no longer wish to express their appreciation for them.

      If the user has not liked the author, this method will throw a NotFoundException. If the specified author does not exist, a NotFoundException is thrown. If there is an error while deleting the record, an InternalServerErrorException is thrown.

      InternalServerErrorException - If there is an error while deleting the record from the database.

    • Parameters

      • bookId: string

        The ID of the book that the user wants to unlike.

      • userId: string

        The ID of the user who wants to unlike the book.

      Returns Promise<{ bookId: string; userId: string }>

      A promise resolving to the deleted record indicating that the user no longer likes the book.

      Deletes a record indicating that a user likes a specific book. This method is used to allow users to remove their like from a book if they no longer wish to express their appreciation for it.

      If the user has not liked the book, this method will throw a NotFoundException. If the specified book does not exist, a NotFoundException is thrown. If there is an error while deleting the record, an InternalServerErrorException is thrown.

      InternalServerErrorException - If there is an error while deleting the record from the database.

    • Parameters

      • commentId: string

        The ID of the comment to be updated.

      • updateCommentDto: UpdateCommentDto

        An object containing the new text for the comment. The text must be between 1 and 500 characters long.

      • userId: string

      Returns Promise<
          {
              bookId: string;
              createdAt: Date;
              id: string;
              text: string;
              userId: string;
          },
      >

      A promise resolving to the updated comment.

      Updates the text of an existing comment identified by its ID. The new text for the comment is provided in the request body. This method allows users to edit their comments after they have been created, enabling them to correct mistakes or update their opinions.

      NotFoundException - If the specified comment does not exist in the database.

      InternalServerErrorException - If there is an error while updating the comment in the database.

      ForbiddenException - If the user is not the owner of the comment.

    • Parameters

      • bookId: string

        The ID of the book for which the rating is to be updated.

      • userId: string

        The ID of the user who is updating the rating.

      • updateRatingDto: UpdateRatingDto

        The DTO containing the new rating score.

      Returns Promise<{ bookId: string; createdAt: Date; score: number; userId: string }>

      A promise resolving to the updated rating record.

      Updates an existing rating record for a specific book by a user. This method allows users to change their rating for a book, which helps in maintaining accurate and up-to-date book ratings.

      If the specified book does not exist, a NotFoundException is thrown. If there is an error while updating the rating record, an InternalServerErrorException is thrown.

      InternalServerErrorException - If there is an error while updating the rating record in the database.

      NotFoundException - If the specified book or rating does not exist in the database.