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

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

const memberSchema = new mongoose.Schema<IMemberSchema>({
    firstName: String,
    lastName: String,
    email: String,
    phone: String,
    address: String,
    registerAt: String,
    registerAt_unix: Number,
    payMonth: Number,
    services: [String],
    planUpdatedAt: String,
    planUpdatedAt_unix: Number,
    planDelay: Number,
    planDelay_unix: Number,
    planExpAt: String,
    planExpAt_unix: Number,
    active: Boolean,
    gendre: String,
    bodyState: {
        startBodyForm: String,
        currentBodyForm: String,
        startWeight: Number,
        currentWeight: Number,
    }
}, { timestamps: true });

const memberModel: Model<IMemberSchema> = mongoose.models.members || mongoose.model<IMemberSchema>('members', memberSchema);
export default memberModel