Skip to content

Commit

Permalink
fixed missing add user id
Browse files Browse the repository at this point in the history
  • Loading branch information
pik-nik committed Mar 17, 2023
1 parent bbf6ac7 commit 9d5d756
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controllers/workout_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ router.post("/workouts", (req, res) => {
res.redirect("/workouts/new")
return
} else {
const sql = "INSERT INTO workouts (name, workout_date) VALUES ($1, $2) returning workout_id;"
db.query(sql, [req.body.name, req.body.workout_date], (err, dbRes) => {
const sql = "INSERT INTO workouts (name, workout_date, user_id) VALUES ($1, $2, $3) returning workout_id;"
db.query(sql, [req.body.name, req.body.workout_date, req.session.userId], (err, dbRes) => {
// add later req.session.userId or res.locals.currentUser.id
res.redirect(`/workouts/${dbRes.rows[0].workout_id}`)
})
Expand Down
1 change: 1 addition & 0 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DROP TABLE workouts;
DROP TABLE exercises;
DROP TABLE workout_exercise_junction;
DROP TABLE log_workout_entries;
DROP TABLE users;

CREATE TABLE workouts (
workout_id SERIAL PRIMARY KEY,
Expand Down
Empty file added latest.dump
Empty file.

0 comments on commit 9d5d756

Please sign in to comment.