import mongoose from "mongoose";

const JobSchema = new mongoose.Schema(
  {
    title: { type: String, required: true, trim: true, maxlength: 200 },
    department: { type: String, required: true, trim: true },
    location: { type: String, required: true, trim: true, maxlength: 100 },
    employmentType: { type: String, required: true, enum: ["Full-time", "Part-time", "Contract", "Internship"] },
    description: { type: String, required: true },
    responsibilities: { type: [String], default: [] },
    requirements: { type: [String], default: [] },
    applicationUrl: { type: String, required: true },
    tags: { type: [String], default: [] },
    status: { type: String, required: true, enum: ["Draft", "Published"], default: "Draft" },
  },
  { timestamps: true }
);

JobSchema.index({ createdAt: -1 });

const JobModel = mongoose.models.Job || mongoose.model("Job", JobSchema);

export { JobModel };


