Ver Fonte

Create model and documentation for session object.

Lee Morgan há 1 ano atrás
pai
commit
2c9f6809d3
3 ficheiros alterados com 58 adições e 0 exclusões
  1. 1 0
      controllers/workout.js
  2. 34 0
      documentation/data.js
  3. 23 0
      models/Session.js

+ 1 - 0
controllers/workout.js

@@ -36,6 +36,7 @@ const createWorkout = (data, userId)=>{
  */
 const responseWorkout = (workout)=>{
     return {
+        id: workout._id,
         name: workout.name,
         exercises: workout.exercises
     };

+ 34 - 0
documentation/data.js

@@ -179,5 +179,39 @@ window.data = [
             type: "[Workout]",
             desc: "List of workouts for the logged in user"
         }]
+    },
+    {
+        type: "object",
+        title: "Session",
+        id: "session",
+        auth: false,
+        description: "An instance of a workout",
+        properties: [
+            {
+                name: "id",
+                type: "String",
+                desc: "Unique ID of the session"
+            },
+            {
+                name: "start",
+                type: "Date",
+                desc: "Date/Time when session started"
+            },
+            {
+                name: "end",
+                type: "Date",
+                desc: "Date/Time when session finished"
+            },
+            {
+                name: "notes",
+                type: "String (optional)",
+                desc: "Notes from the user about the session"
+            },
+            {
+                name: "exercises",
+                type: "[Object]",
+                desc: "List of flexible objects. Structure of each object based on the type of exercise"
+            }
+        ]
     }
 ]

+ 23 - 0
models/Session.js

@@ -0,0 +1,23 @@
+import mongoose from "mongoose";
+
+const SessionSchema = mongoose.Schema({
+    workout: {
+        type: mongoose.Schema.Types.ObjectId,
+        required: true,
+    },
+    start: {
+        type: Date,
+        required: true
+    },
+    end: {
+        type: Date,
+        required: true
+    },
+    notes: {
+        type: String,
+        required: false
+    },
+    exercises: [{}]
+});
+
+export default mongoose.model("session", SessionSchema);