fac-17 / week-6-glan

PostgreSQL
https://week-6-glan.herokuapp.com/
0 stars 4 forks source link

postData.js #32

Closed xIrusux closed 5 years ago

xIrusux commented 5 years ago

In your postData line 5 just a comment that you do not have to use a template literal. It is 'inbuilt' within pg that in the query function the template literal is not needed and you can simply reference the values from the following array (which you have in line 6)

you could have therefore simply written something like the below. I am mentioning this change as I think the whole reason for this feature is to avoid attacks as you are only referencing the data you are inputting rather than naming the variables of this data. Hope this makes sense. Have a look at the link I shared below (official documentation with an example)

"INSERT INTO warriors (warrior_name, warrior_c1, warrior_c2, warrior_c3) VALUES ($1, $2, $3, $4", [warrior_name, warrior_c1, warrior_c2, warrior_c3],

https://node-postgres.com/features/queries