/***
 *
 * @description This model represent the users collection schema in mongodb
 * * source : https://mongoosejs.com/docs/guide.html
 */

import mongoose, { Model } from 'mongoose';
import { IUserSchema } from '@/types/IDB';

const userSchema = new mongoose.Schema<IUserSchema>({
  username: {
    type: String,
    required: true,
  },
  password: {
    type: String,
    required: true
  },
  accountType: {
    type: String,
    required: true,
    default: 'ADMIN',
  },
  settings: {
    appName: String,
    appNameEN: String,
    gymName: String,
    email: String,
    phone: String,
    address: String,
    showLogo: Boolean,
    logo: String,
    currencySymbol: String,
  },
  token: {
    value: {
      type: String,
      required: true,
    },
    expiresAt: {
      type: Number,
      required: true,
    }
  }
}, { timestamps: true });

const userModel: Model<IUserSchema> = mongoose.models.users || mongoose.model<IUserSchema>('users', userSchema);
export default userModel