import mongoose, { Document } from 'mongoose';

import { MODEL_NAMES } from './_models';
import { IBorrowerGroup } from '../interfaces/group.interface';

export interface ICustomerGroupDocument extends IBorrowerGroup, Document {
}

export const CustomerGroupSchema = new mongoose.Schema(
  {
    groupName: {
      type: String,
      trim: true,
      required: true,
    },
    borrowerId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: MODEL_NAMES.borrowers,
      required: true,
    },
    items: [String],
    __v: { type: Number, select: false },
  },
  { timestamps: true }
);

export const CustomerGroupModel: mongoose.Model<ICustomerGroupDocument> = mongoose.model<ICustomerGroupDocument>(MODEL_NAMES.customerGroups, CustomerGroupSchema);
