File size: 2,557 Bytes
d491754
eb78df6
 
 
 
d491754
 
 
 
86f4808
2703d15
 
eb78df6
 
 
 
 
 
 
2703d15
eb78df6
 
 
2703d15
 
eb78df6
 
 
86f4808
2703d15
 
 
fc659a3
 
3daae40
d491754
 
 
 
eb78df6
2703d15
b7f0477
eb78df6
 
 
 
 
 
 
2703d15
eb78df6
 
 
2703d15
 
eb78df6
 
 
2703d15
b7f0477
2703d15
 
 
 
fc659a3
 
3daae40
d491754
 
 
 
 
fc659a3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import mongoose from "mongoose";
import { FitnessGoal } from "@common/enums/fitness-goal.enum";
import { FitnessLevel } from "@common/enums/fitness-level.enum";
import { Place } from "@common/enums/place.enum";

const { Schema } = mongoose;

export interface IWorkout {
    name: string;
    description: string;
    type: string;
    created_by: mongoose.Types.ObjectId;
    image: string;
    fitness_level: FitnessLevel;
    fitness_goal: FitnessGoal;
    place: [Place];
    min_per_day: number;
    total_number_days: number;
    template_weeks: [
        {
            week_number: number;
            week_name: string,
            week_description: string,
            days: [
                {
                    day_number: number,
                    total_number_exercises: number,
                    day_type: string,
                    exercises: [mongoose.Types.ObjectId],
                },
            ],
        },
    ],
    aiGenerated: boolean;
    isDeleted: boolean;
}

const workoutSchema = new Schema({
    name: { type: String, required: true, unique: true, dropDups: true },
    description: { type: String, required: true },
    type: { type: String, required: true },
    created_by: { type: mongoose.Types.ObjectId, ref: "admins" },
    image: { type: String },
    fitness_level: { type: String, enum: FitnessLevel, required: true, },
    fitness_goal: { type: String, enum: FitnessGoal, required: true, },
    place: [{ type: String, enum: Place, required: true, }],
    min_per_day: { type: Number, required: true, },
    total_number_days: { type: Number, required: true, },
    template_weeks: [
        {
            week_number: { type: Number, required: true, },
            week_name: { type: String, required: true, },
            week_description: { type: String, required: true, },
            days: [
                {
                    day_number: { type: Number, required: true, enum: [1, 2, 3, 4, 5, 6, 7] },
                    total_number_exercises: { type: Number, required: true, },
                    day_type: { type: String, required: true, },
                    exercises: [
                        { type: mongoose.Types.ObjectId, ref: "exercises" },
                    ],
                },
            ],
        },
    ],
    aiGenerated: { type: Boolean, required: true, default: false },
    isDeleted: { type: Boolean, default: false },
});


export type WorkoutDocument = IWorkout & mongoose.Document;

export const Workout = mongoose.model<WorkoutDocument>("workouts", workoutSchema);