import { Schema, model } from 'mongoose';
import { paginate, toJSON } from '@/shared/utils/plugins';
import { IMasterBankDoc, IMasterBankModel } from './bank.interface';

const masterBankSchema = new Schema<IMasterBankDoc>(
  {
    name: {
      type: String,
      required: true,
      trim: true,
    },
    nameLower: {
      type: String,
      required: true,
      trim: true,
      index: true,
    },
    createdBy: {
      type: Schema.Types.ObjectId,
      ref: 'User',
    },
    updatedBy: {
      type: Schema.Types.ObjectId,
      ref: 'User',
    },
  },
  { timestamps: true },
);



masterBankSchema.plugin(toJSON);
masterBankSchema.plugin(paginate);

export const MasterBank = model<IMasterBankDoc, IMasterBankModel>(
  'MasterBank',
  masterBankSchema,
);
