const mongoose = require("mongoose");


const orderSchema = new mongoose.Schema({
	userId: {
		type: String
	},
	products : [
			{
				productId: {
					type: String,
					required: [true, "Product id is required!"]
				},
				quantity : {
					type : Number,
					default : 1
				},
				price:{
					type: Number
				}
			}
		],
	totalAmount: {
		type: Number,
	},
	purchasedOn : {
		type: Date,
		default : new Date()
	}
})

const Order = mongoose.model("orders", orderSchema);

module.exports = Order;