import mongoose from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface IAuditorAccess {
  email: string;
  hashedPassword: string;
}

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

export interface IAuditorAccessLean extends IAuditorAccess {
  _id: mongoose.Types.ObjectId;
  createdAt: Date;
  updatedAt: Date;
}

export interface IAuditorAccessPlain extends IAuditorAccess {
  _id: string;
  createdAt: Date;
  updatedAt: Date;
}

export type AuditorAccessModel = mongoose.Model<IAuditorAccess>;

export const AuditorAccessSchema = new mongoose.Schema<IAuditorAccess, AuditorAccessModel>(
  {
    email: {
      type: String,
    },
    hashedPassword: {
      type: String,
    },
  },
  {
    timestamps: { createdAt: true, updatedAt: true },
    versionKey: false,
  },
);

export const AuditorAccess = mongoose.model<IAuditorAccess, AuditorAccessModel>(MODEL_NAMES.auditorAccess, AuditorAccessSchema);
