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

const reviewSchema = new Schema({
    userId: {
        type: Schema.Types.ObjectId,
        ref: "User",
        required: true
    },
    type: {
        type: String,
        enum: ["Shop", "Product"],
        required: true
    },
    adminId: {
        type: Schema.Types.ObjectId,
        ref: "Admin",
        required: true
    },
    shopId: {
        type: Schema.Types.ObjectId,
        ref: "Shop"
    },
    productId:{
        type: Schema.Types.ObjectId,
        ref: "Product"
    },
    stars:{
        type: Number,
        enum: [1, 2, 3, 4, 5],
        required: true
    },
    text:{
        type: String,
        required: true
    },
    createdAt: {
        type: Date,
        default: Date.now,
    }
});

const reviewModel = mongoose.model("Review", reviewSchema);
module.exports = reviewModel;