Skip to content
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

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

kunaidyp
Copy link
Contributor

@kunaidyp kunaidyp commented Dec 5, 2023

Closes issue #10

Copy link
Collaborator

@joshualipton joshualipton left a 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

Comment on lines 33 to 37
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.');
Copy link
Collaborator

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.

// CREATE a new item
valueRouter.post('/', async (req, res) => {
try {
const { itemId, itemName, quantityType, quantity, price } = req.body;
Copy link
Member

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.

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 *',
Copy link
Member

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.


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 },
Copy link
Member

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.

@joshualipton joshualipton merged commit fc66de5 into dev Jan 9, 2024
2 checks passed
} catch (err) {
res.status(500).send(err.message);
}
});

valueRouter.delete('/:id', async (req, res) => {
// CREATE a new item
valueRouter.post('/', async (req, res) => {
Copy link
Contributor

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(
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants