/* eslint-disable no-param-reassign */
import { Schema, model } from 'mongoose';
import { ICompanyInfo } from '../utils/types';

const companySchema = new Schema<ICompanyInfo>(
  {
    companyName: {
      type: String,
      required: true,
    },
    rcNumber: {
      type: String,
      unique: true,
      required: true,
    },
    email: {
      type: String,
      required: true,
      unique: true,
    },
    phoneNumber: {
      type: String,
      required: true,
    },
    address: {
      type: String,
      required: true,
    },
  },
  {
    timestamps: true,
    toJSON: {
      transform(_doc, ret) {
        delete ret.__v;
      },
    },
  },
);

const Company = model<ICompanyInfo>('Company', companySchema);

export = Company;
