const mongoose = require('mongoose');
const OrderStatus = require('../domain/value-objects/OrderStatus');

const orderSchema = new mongoose.Schema({
    bookId: { type: mongoose.Schema.Types.ObjectId, ref: 'Book', required: true },
    customerName: { type: String, required: true },
    status: { 
        type: String, 
        enum: Object.values(OrderStatus), 
        default: OrderStatus.PENDING 
    },
    orderDate: { type: Date, default: Date.now }
});

module.exports = mongoose.model('Order', orderSchema);