text: const mongoose = require("mongoose");
  const { Schema } = mongoose;
  
  const orderSchema = new Schema(
    {
      user: {
        type: mongoose.Schema.Types.ObjectId,
        required: true,
        ref: "User",
      },
  
      orderItems: [
        {
          name: { type: String, required: true },
          qty: { type: Number, required: true },
          image: { type: String, required: true },
          price: { type: Number, required: true },
          product: {
            type: mongoose.Schema.Types.ObjectId,
            required: true,
            ref: "Product",
          },
        },
      ],
  
      shippingAdd: {
        address: { type: String, required: true },
        city: { type: String, required: true },
        country: { type: String, required: true },
        zipcode: { type: String, required: true },
      },
      paymentType: {
        type: String,
        required: true,
      },
      paymentResult: {
        id: { type: String },
        status: { type: String },
        update_time: { type: String },
        email_address: { type: String },
      },
      taxPrice: {
        type: Number,
        required: true,
        default: 0.0,
      },
  
      shippingFee: {
        type: Number,
        required: true,
        default: 0.0,
      },
  
      totalPrice: {
        type: Number,
        required: true,
        default: 0.0,
      },
  
      isPaid: {
        type: Boolean,
        required: true,
        default: false,
      },
  
      paidAt: {
        type: Date,
      },
  
      isDelivered: {
        type: Boolean,
        required: true,
        default: false,
      },
  
      deliveredAt: {
        type: Date
      },
    },
    {
      timestamps: true,
    }
  );
  
  const Order = mongoose.model("Order", orderSchema);
  
  module.exports = Order;
  