import mongoose from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface ITransactionAttachedFile {
  borrowerId: mongoose.Types.ObjectId;
  filename: string;
  originalName: string;
  effectiveDate: string;
  userId: string;
}

export interface ITransactionAttachedFileDoc extends ITransactionAttachedFile, mongoose.Document {
}

export const TransactionAttachedFileSchema = new mongoose.Schema(
  {
    borrowerId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: MODEL_NAMES.borrowers,
      required: true,
    },
    filename: {
      type: String,
      required: true,
      trim: true,
    },
    originalName: {
      type: String,
      required: true,
      trim: true,
    },
    effectiveDate: {
      type: String,
      required: true,
      trim: true,
    },
    userId: {
      type: String,
      required: false,
    },
    __v: { type: Number, select: false },
  },
  { timestamps: true }
);

export const TransactionAttachedFileModel: mongoose.Model<ITransactionAttachedFileDoc> = mongoose.model<ITransactionAttachedFileDoc>(MODEL_NAMES.transactionAttachedFiles, TransactionAttachedFileSchema);
