text: const mongoose = require("mongoose")
  
  // Product model
  const productSchema = new mongoose.Schema({
      name: {
          type: String,
          required: [true, "Please enter a name for the product"],
          trim: true,
          maxLength: [100, "Product name cannot exeed 100 characters long"]
      },
      price: {
          type: Number,
          required: [true, "Please enter a price for the product"],
          maxLength: [5, "Product price cannot exeed 5 characters long"],
          default: 0.0
      },
      description: {
          type: String,
          required: [true, "Please enter a description for the product"]
      },
      tatings: {
          type: Number,
          default: 0
      },
      images: [
          {
              public_id: {
                  type: String,
                  required: true,
              },
              url: {
                  type: String,
                  required: true,
              },
          }
      ],
      category: {
          type: String,
          required: [true, "Please select a category for this product"],
          enum: {
              values: [
                  "Components",
                  "Computers",
                  "Electronics",
                  "Gaming",
                  "Networking",
                  "Office",
                  "Software",
              ],
              message: "Please select the correct category for this product"
          }
      },
      seller: {
          type: String,
          required: [true, "Please enter the product seller name"]
      },
      stock: {
          type: Number,
          required: [true, "Please enter product stock quantity"],
          maxLength: [5, "Product name cannot exceed 5 characters"],
          default: 0
      },
      numberOfReviews: {
          type: Number,
          default: 0,
      },
      reviews: [
          {
              name: {
                  type: String,
                  required: true
              },
              rating: {
                  type: Number,
                  required: true
              },
              comment: {
                  type: String,
                  required: true
              }
          }
      ],
      createdAt: {
          type: Date,
          default: Date.now
      }
  })
  
  module.exports = mongoose.model("Product", productSchema)