const mongoose = require("mongoose");

const serviceSchema = new mongoose.Schema(
  {
    serviceName: {
      type: String,
      required: [true, "Service name is required"],
      trim: true,
      minlength: [3, "Service name must be at least 3 characters long"],
      maxlength: [150, "Service name cannot exceed 150 characters"],
    },
    serviceCost: {
      type: Number,
      required: true,
    },
    orgId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "Organization",
      required: [true, "Organization ID is required"],
    },
    status: {
      type: Boolean,
      default: true, // active by default
    },
    isDeleted: {
      type: Boolean,
      default: false, // soft delete flag
    },
    createdBy: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
      required: true,
    },
    updatedBy: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
      // required: true,
      default: null
    },
    updatedAt: {
      type: Date,
      default: null,
    }
  },
  {
    timestamps: {
      createdAt: true,
      updatedAt: false,
    }
  }
);

module.exports = mongoose.model("Service", serviceSchema);
