const mongoose = require('mongoose');

const companySchema = new mongoose.Schema(
  {
    // Company Name
    name: {
      type: String,
      required: [true, 'Company name is required.'],
      trim: true, // Trim whitespace
      unique: true, // Ensure company names are unique
      minlength: [2, 'Company name must be at least 2 characters long.'],
      maxlength: [100, 'Company name cannot exceed 100 characters.']
    },
    
    // Profile URL for company image/logo
    profile_url: {
      type: String,
      default: '', // Default to an empty string if no image is uploaded
         },
    shopType: {
      type: String,
      enum: ["retail", "manufacturing"], 
      default: 'retail',  // Default to 'retail'
    }
    
  },
  { 
    timestamps: true 
  }
);

module.exports = mongoose.model('Company', companySchema);
