Skip to content

[JITERA] Create Product Image Service

chi le requested to merge feat/product-image-service-1746769110 into main

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

  1. ProductImage Model:

    • A new model for ProductImage has been created in the models directory. This model defines the schema for product images in the database, ensuring that all necessary fields are included.
  2. Product Image Service:

    • A new service file productImageService.js has been created in the services directory. 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.

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.

Merge request reports