import mongoose, { Model } from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface IAvailabilitySignedData {
  _id?: mongoose.Types.ObjectId;
  bbcDateId?: mongoose.Types.ObjectId;
  data: any;
}

type IAvailabilitySignedDataModel = Model<IAvailabilitySignedData, {}, {}>;

export const AvailabilitySignedDataSchema = new mongoose.Schema<IAvailabilitySignedData, IAvailabilitySignedDataModel>(
  {
    bbcDateId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: MODEL_NAMES.BBCDates,
      required: false,
    },
    data: {
      type: mongoose.Schema.Types.Mixed,
    },
  },
  {
    timestamps: { createdAt: false, updatedAt: false },
    versionKey: false,
  },
);

export const AvailabilitySignedData = mongoose.model<IAvailabilitySignedData, IAvailabilitySignedDataModel>(MODEL_NAMES.availabilitySignedData, AvailabilitySignedDataSchema);
