Track your most recent workouts
Track your workouts with Fitness Tracker. The app will keep track of every exercise in your workout. The app dashboard will display weekly summary graphs of all workouts done in a week.
Running seeders/seed.js is optional to have a prepopulated database.
// add exercise
app.put("/api/workouts/:id", (req, res) => {
db.Workout.findOneAndUpdate(
{ _id: req.params.id },
{
$inc: { totalDuration: req.body.duration },
$push: { exercises: req.body }
},
{ new: true }).then(dbWorkout => {
res.json(dbWorkout);
}).catch(err => {
res.json(err);
});
});