import mongoose, { Document, Schema } from "mongoose"; export interface IProduct extends Document { categoryIDs: mongoose.Types.ObjectId[]; userID: mongoose.Types.ObjectId; photos: { coverPhotoPath: string; isPrimary: boolean; }[]; isAvailable: boolean; description: string; isActive: boolean; title: string; price: number; } const productSchema = new Schema( { categoryIDs: { type: [mongoose.Schema.Types.ObjectId], index: true, default: [] }, userID: { type: mongoose.Schema.Types.ObjectId, index: true }, title: { type: String, required: true, trim: true }, description: { type: String, default: "", trim: true }, price: { type: Number, required: true, min: 0 }, photos: [ { coverPhotoPath: { type: String }, isPrimary: { type: Boolean, default: false }, _id: false } ], isActive: { type: Boolean, default: true }, isAvailable: { type: Boolean, default: true }, }, { timestamps: true, } ); export const Product = mongoose.models.Product || mongoose.model("Product", productSchema);