import { Schema, model } from "mongoose";
import * as env from "../config/env.config";

const notificationSchema = new Schema<env.Notification>(
  {
    user: {
      type: Schema.Types.ObjectId,
      required: [true, "can't be blank"],
      ref: "User",
      index: true,
    },
    message: {
      type: String,
      required: [true, "can't be blank"],
    },
    type: {
      type: String,
      enum: ["info", "success", "warning", "error", "danger"],
      default: "info",
    },
    isRead: {
      type: Boolean,
      default: false,
    },
  },
  {
    timestamps: true,
    strict: true,
    collection: "Notification",
  }
);

const Notification = model<env.Notification>("Notification", notificationSchema);

export default Notification;
