Skip to content

Commit

Permalink
added first and last name to db and create user route
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheryl Chen authored and Cheryl Chen committed Feb 26, 2024
1 parent 95f8286 commit 0b8f8a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ userRouter.get('/:uid', async (req, res) => {

userRouter.post('/create', async (req, res) => {
try {
const { id, email, type, approved, approvedOn } = req.body;
const { id, email, type, approved, approvedOn, firstName, lastName } = req.body;
await db.query(
`INSERT INTO users (id, email, "type", approved, approved_on) VALUES ($1, $2, $3, $4, $5);`,
[id, email, type, approved, approvedOn],
`INSERT INTO users (id, email, "type", approved, approved_on, first_name, last_name) VALUES ($1, $2, $3, $4, $5, $6, $7);`,
[id, email, type, approved, approvedOn, firstName, lastName],
);
res.status(201).json({
id,
Expand Down
2 changes: 2 additions & 0 deletions server/schema/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ CREATE TABLE users (
type account_type NOT NULL,
approved BOOLEAN NOT NULL,
approved_on DATE NOT NULL,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL
);

0 comments on commit 0b8f8a9

Please sign in to comment.