const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const productSchema = new Schema({
    adminId:{
        type: Schema.Types.ObjectId,
        ref: "Admin",
        required: true
    },
    shopId: {
        type: Schema.Types.ObjectId,
        ref: "Shop",
        requried: true
    },
    name:{
        type: String,
        required: true
    },
    StockQuantity:{
        type: Number,
        required: true 
    },
    discount:{
        type: Number
    },
    price:{
        type: Number,
        required: true
    },
    category:{
        type: Schema.Types.ObjectId,
        ref: "Category",
        required: true
    },
    brandName:{ 
        type: String,
        required: true
    },
    productImages:{
        type: [String]
    },
    variants:[{ 
        type: Schema.Types.ObjectId,
        ref: "Product",
    }],
    starRating: {
        type: Number,
        enum: [1, 2, 3, 4, 5]
    },
    favouriteBy:[{
        type: Schema.Types.ObjectId,
        ref: "User"
    }]
});

const productModel = mongoose.model("Product", productSchema);
module.exports = productModel;