Hello gyus
i am working on the Exercice tracker project and i am facing problems concerning the description and the duration fields, the problem is that when adding an exercise for a specific user, empty fields are allowed
i am affraid the problem is caused from my schema, here is mine, i used a nested schema ( a subdocument )
is it a good practice to split it, i mean by that creating a 2 seperates schema one for the user log and one for the exercise , this would not cause data redundancy ?
const mongoose = require("mongoose")
let ExerciseTracker;
// creating user log nested schema
const userLogSchema = new mongoose.Schema({
description:{type:String,required:true},
duration: {type:String,required:true},
date: {type:String}
});
// creating a user schema
const exerciseTrackerSchema = new mongoose.Schema({
username: {type:String,required:true},
count: {
type: Number,
default: 0
},
log: {
type: [userLogSchema],
}
});
// ceating a model
ExerciseTracker = mongoose.model("ExerciseTracker", exerciseTrackerSchema);
exports.ExerciseTrackerModel = ExerciseTracker;
Hi @laurentlabine
thanks for your reply
yeah you are right this should resolve the problem, but i tried to come up with a solution similar to the freecodecamp solution, you see, when you submit the form without filling for instance the description field you get a “Path description is required.” response.
so i split my schema into 2 schemas one for the user and one for the exercise and i ended up with a solution closer to the fcc solution.