[JITERA] Implement Book Service for Managing Book Data
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
createBookfunction: 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
getBookfunction: This function retrieves a book by its ID. It handles cases where the book may not be found and returns appropriate error messages. -
Added
updateBookfunction: 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
deleteBookfunction: 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.