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

Feature/endpoint for removing image #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tomi
Copy link
Contributor

@tomi tomi commented Apr 29, 2019

Adds an endpoint which user can use to remove images he/she has uploaded

@tomi tomi force-pushed the feature/endpoint-for-removing-image branch from ed3ed40 to e2bd976 Compare April 29, 2019 12:45
return knex.raw(`
SELECT *
FROM images
WHERE id = ${req.params.id}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prone to SQL injection. Should be...

knex.raw(`... WHERE id = ?`,  req.params.id).then(...);

return Promise.all(rows.map(r => {
return knex.raw(`
DELETE FROM votes
WHERE id = ${r.id}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

*/
function delImg(id) {
return knex.raw(`
DELETE FROM images WHERE id = ${id}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

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.

2 participants