import mongoose, { Document } from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface IGlobals {
  setting: string;
  value: any;
  userID: string;
}

export interface IGlobalsDoc extends IGlobals, Document {
}

export const GlobalsSchema = new mongoose.Schema(
  {
    setting: {
      type: String,
      required: true,
    },
    value: {
      type: mongoose.Schema.Types.Mixed,
      required: true,
    },
    userID: {
      type: String,
    },
    __v: { type: Number, select: false },
  },
  { timestamps: true },
);

export const GlobalsModel: mongoose.Model<IGlobalsDoc> = mongoose.model<IGlobalsDoc>(MODEL_NAMES.globals, GlobalsSchema);
