// 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: undefined,
    index: true,
  },
  nationalId: {
    type: String,
    required: false,
    unique: true,
    sparse: true,
    index: true,
  },
  businessID: {
    type: String,
    required: false,
    unique: true,
    sparse: true,
    index: true,
  },
  isPrivatePerson: {
    type: Boolean,
    default: true,
  },
  data: {
    type: mongooseSchema.Types.Mixed,
    default: {},
  },
};

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

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