-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set up market values get and post #15
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, very good first PR! Please don't forget to add me as a reviewer next time, it made me sad
routes/valueRouter.js
Outdated
if (!itemId) throw new Error('Item ID is required.'); | ||
if (!itemName) throw new Error('Item name is required.'); | ||
if (!quantityType) throw new Error('Quantity type is required.'); | ||
if (!quantity) throw new Error('Quantity is required.'); | ||
if (!price) throw new Error('Price is required.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're gonna do frontend validation for this so this is likely redundant. We will delete these lines.
routes/valueRouter.js
Outdated
// CREATE a new item | ||
valueRouter.post('/', async (req, res) => { | ||
try { | ||
const { itemId, itemName, quantityType, quantity, price } = req.body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the itemId part as me and Josh just added a way for the id to auto increment. For your INSERT statement, you wont need to indicate an itemId as it is automatically serialized.
routes/valueRouter.js
Outdated
if (!price) throw new Error('Price is required.'); | ||
|
||
const newItem = await db.query( | ||
'INSERT INTO fair_market_value (item_id, item_name, quantity_type, quantity, price) VALUES ($(itemId), $(itemName), $(quantityType), $(quantity), $(price)) RETURNING *', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the itemId part as me and Josh just added a way for the id to auto increment. For your INSERT statement, you wont need to indicate an itemId as it is automatically serialized.
routes/valueRouter.js
Outdated
|
||
const newItem = await db.query( | ||
'INSERT INTO fair_market_value (item_id, item_name, quantity_type, quantity, price) VALUES ($(itemId), $(itemName), $(quantityType), $(quantity), $(price)) RETURNING *', | ||
{ itemId, itemName, quantityType, quantity, price }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the itemId part as me and Josh just added a way for the id to auto increment. For your INSERT statement, you wont need to indicate an itemId as it is automatically serialized.
} catch (err) { | ||
res.status(500).send(err.message); | ||
} | ||
}); | ||
|
||
valueRouter.delete('/:id', async (req, res) => { | ||
// CREATE a new item | ||
valueRouter.post('/', async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <consistent-return> reported by reviewdog 🐶
Expected to return a value at the end of async arrow function.
volunteerHours, | ||
}, | ||
const { itemName, quantityType, quantity, price } = req.body; | ||
const newItem = await db.query( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [eslint] <no-unused-vars> reported by reviewdog 🐶
'newItem' is assigned a value but never used.
Closes issue #10