Skip to content

[JITERA] Implement Book Service for Managing Book Data

Klebson Leite requested to merge feat/add-book-service-1747755081 into main

Overview

This pull request introduces a new service for managing book data within the application. The bookService.js file provides essential functions for creating, retrieving, updating, and deleting book records.

Changes Explained

  • Added createBook function: This function allows the addition of new book records to the database. It takes book details as input and returns the created book object.

  • Added getBook function: This function retrieves a book by its ID. It handles cases where the book may not be found and returns appropriate error messages.

  • Added updateBook function: This function updates the details of an existing book. It checks if the book exists before attempting to update and returns the updated book object.

  • Added deleteBook function: This function removes a book from the database based on its ID. It ensures that the book exists before deletion and returns a success message upon completion.

  • Error Handling: Implemented error handling for all functions to ensure that appropriate messages are returned in case of failures.

  • Unit Tests: Added unit tests for each function to ensure reliability and correctness of the service.

This new service will streamline the management of book data and provide a solid foundation for future features related to books.

Merge request reports