import mongoose, { Model } from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface IDeletedRecord {
  DBCollection: string;
  recordId: mongoose.Types.ObjectId;
  record: Object;
}

type DeletedRecordModel = Model<IDeletedRecord, {}, {}>;

export const DeletedRecordSchema = new mongoose.Schema<IDeletedRecord, DeletedRecordModel>(
  {
    DBCollection: {
      type: String,
      trim: true,
    },
    recordId: {
      type: mongoose.Schema.Types.ObjectId,
      required: true,
    },
    record: {
      type: mongoose.Schema.Types.Mixed,
    },
  },
  { timestamps: false },
);

export const DeletedRecord = mongoose.model<IDeletedRecord, DeletedRecordModel>(MODEL_NAMES.deletedRecords, DeletedRecordSchema);
