// Connections
import mongoConnection from "$connections/mongo/mongo.connection.js";

import mongoose from "mongoose";
const mongooseSchema = mongoose.Schema;

export const schemaModel = {
  user: {
    type: mongooseSchema.Types.ObjectId,
    ref: "User",
    default: "000000000000000000000000",
  },
  error: {
    type: Object,
    default: null,
  },
  message: {
    type: String,
    default: null,
  },
  type: {
    type: String,
    enum: ["user", "system"],
    default: "system",
  },
  level: {
    type: String,
    enum: ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"],
    default: "INFO",
  },
};

export const schema = new mongooseSchema(schemaModel, { timestamps: true });

export default mongoConnection.model("Log", schema);
