import mongoose, { Model } from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface IScorecard {
  name: string;
}

export interface IScorecardDoc extends IScorecard, Document {
  _id: mongoose.Types.ObjectId;
  createdAt: Date;
  updatedAt: Date;
}

export interface IScorecardLean extends IScorecard {
  _id: mongoose.Types.ObjectId;
  createdAt: Date;
  updatedAt: Date;
}

export interface IScorecardPlain extends IScorecard {
  _id: string;
}

export type TScorecardModel = Model<IScorecard>;

export const ScorecardSchema = new mongoose.Schema<IScorecard, TScorecardModel>(
  {
    name: {
      type: String,
      required: true,
    },
  },
  {
    timestamps: { createdAt: true, updatedAt: true },
    versionKey: false,
  },
);

export const Scorecard = mongoose.model<IScorecard, TScorecardModel>(MODEL_NAMES.scorecard, ScorecardSchema);
