const mongoose = require('mongoose');

const CafeOrderTransferSchema = new mongoose.Schema({
  fromUserId: {
    type: mongoose.Schema.Types.ObjectId, // Assuming it's a reference to a User
    ref: 'User',
    required: true
  },
  toUserId: {
    type: mongoose.Schema.Types.ObjectId, // Assuming it's a reference to a User
    ref: 'User',
    required: true
  },
  orderId: {
    type: mongoose.Schema.Types.ObjectId, // Assuming it's a reference to an Order
    ref: 'CafeOrder',
    required: true
  },
  status: {
    type: String,
    enum: ['pending', 'accepted', 'rejected','returned'], // Define allowed status values
    default: 'pending',
    required: true
  }
}, {
  timestamps: true // Adds createdAt and updatedAt fields automatically
});

const CafeOrderTransfer = mongoose.model('CafeOrderTransfer', CafeOrderTransferSchema);

module.exports = CafeOrderTransfer;
