moahmedwafy commited on
Commit
f1528d2
·
1 Parent(s): 4d593f3

feat: create muscle and equiment models

Browse files
src/common/models/equipment.model.ts ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import mongoose from "mongoose";
2
+ const { Schema } = mongoose;
3
+
4
+ export interface IEquipment {
5
+ name: string;
6
+ image: string;
7
+ }
8
+
9
+ const equipmentSchema = new Schema({
10
+ name: { type: String, required: true, unique: true, dropDups: true },
11
+ image: { type: String, required: true },
12
+ });
13
+
14
+ export type EquipmentDocument = IEquipment & mongoose.Document;
15
+
16
+ export const Equipment = mongoose.model<EquipmentDocument>(
17
+ "equipments",
18
+ equipmentSchema
19
+ );
src/common/models/exercise.model.ts CHANGED
@@ -1,4 +1,4 @@
1
- import mongoose from "mongoose";
2
  const { Schema } = mongoose;
3
 
4
  export interface IExercise {
@@ -13,8 +13,11 @@ export interface IExercise {
13
  sets: number;
14
  instructions: string;
15
  benefits: string;
16
- targetMuscles: string[]; // refs
17
- equipments: string[]; // refs
 
 
 
18
  media: {
19
  type: "image" | "video";
20
  url: string;
@@ -33,7 +36,10 @@ const exerciseSchema = new Schema({
33
  sets: { type: Number, required: true },
34
  instructions: { type: String, required: true },
35
  benefits: { type: String, required: true },
36
- targetMuscles: [{ type: Schema.Types.ObjectId, ref: "muscles" }],
 
 
 
37
  equipments: [{ type: Schema.Types.ObjectId, ref: "equipments" }],
38
  media: {
39
  type: {
 
1
+ import mongoose, { ObjectId } from "mongoose";
2
  const { Schema } = mongoose;
3
 
4
  export interface IExercise {
 
13
  sets: number;
14
  instructions: string;
15
  benefits: string;
16
+ targetMuscles: {
17
+ primary: ObjectId;
18
+ secondary: ObjectId;
19
+ }
20
+ equipments: ObjectId[];
21
  media: {
22
  type: "image" | "video";
23
  url: string;
 
36
  sets: { type: Number, required: true },
37
  instructions: { type: String, required: true },
38
  benefits: { type: String, required: true },
39
+ targetMuscles: {
40
+ primary: { type: Schema.Types.ObjectId, ref: "muscles" },
41
+ secondary: { type: Schema.Types.ObjectId, ref: "muscles" },
42
+ },
43
  equipments: [{ type: Schema.Types.ObjectId, ref: "equipments" }],
44
  media: {
45
  type: {
src/common/models/muscle.model.ts ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import mongoose from "mongoose";
2
+ const { Schema } = mongoose;
3
+
4
+ export interface IMuscle {
5
+ name: string;
6
+ image: string;
7
+ }
8
+
9
+ const muscleSchema = new Schema({
10
+ name: { type: String, required: true, unique: true, dropDups: true },
11
+ image: { type: String, required: true },
12
+ });
13
+
14
+ export type MuscleDocument = IMuscle & mongoose.Document;
15
+
16
+ export const Muscle = mongoose.model<MuscleDocument>(
17
+ "muscles",
18
+ muscleSchema
19
+ );