[JITERA] Create Product Image Service
Created by: chi-jitera
Overview
This pull request introduces a new service for managing product images, following the structure and conventions used in the existing bookService.js. It includes the creation of a new model for product images and a service file that provides functions for creating, retrieving, updating, and deleting product images.
Changes
-
ProductImage Model:
- A new model for
ProductImagehas been created in themodelsdirectory. This model defines the schema for product images in the database, ensuring that all necessary fields are included.
- A new model for
-
Product Image Service:
- A new service file
productImageService.jshas been created in theservicesdirectory. This file includes the following functions:-
createProductImage(imageData): Validates and saves a new product image to the database. -
getAllProductImages(): Retrieves all product images from the database. -
getProductImageById(imageId): Fetches a specific product image by its ID. -
updateProductImage(imageId, updateData): Validates and updates an existing product image. -
deleteProductImage(imageId): Deletes a product image by its ID.
-
- A new service file
Each function includes error handling to ensure that appropriate messages are returned if operations fail, such as when an image is not found or when required data is missing.
This service will facilitate the management of product images in the application, providing a structured approach to handle image-related operations.