// models/Device.js
const mongoose = require('mongoose');

const deviceSchema = new mongoose.Schema({
  deviceId: {
    type: String,
    required: true,
    unique: true // Ensures each deviceId is unique in the database
  },
  deviceName: {
    type: String,
    default: 'Unknown Device' // Default name if no custom name is provided
  },
  status: {
    type: String,
    enum: ['pending', 'approved', 'rejected'], // Only allow these statuses
    default: 'pending' // Set to 'pending' by default, awaiting admin approval
  },
  addedAt: {
    type: Date,
    default: Date.now // Timestamp for when the device was added
  }
});

const Device = mongoose.model('Device', deviceSchema);

module.exports = Device;
