executing complete insert #650
-
Hi, this should be trivial, but for the life of me, I cannot figure out, how you intended this tho work.
I get:
Of course, there will be a whole bunch of inserts but with no dynamic parameters at all. How can I do that? best wishes! Marc |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @MarcRohrer . If you already have a string you want to run as a query, there is no way to have Postgres.js help you ensure you're doing something safe, and not accidentally eg. allowing sql injection, therefore the method is called Postgres.js mainly works by letting you compose your queries using tagged template literals, also to avoid sql injection and unsafe query creation. Did you read the beginning of the README.md, specifically https://github.com/porsager/postgres#await-sql---result ? Do you have any recommendations for how you think it could be better explained? I'm sorry to hear you didn't find that intuitive / straight forward. |
Beta Was this translation helpful? Give feedback.
Hi @MarcRohrer .
If you already have a string you want to run as a query, there is no way to have Postgres.js help you ensure you're doing something safe, and not accidentally eg. allowing sql injection, therefore the method is called
unsafe
. Check out https://github.com/porsager/postgres#await-sqlunsafequery-args-options---resultPostgres.js mainly works by letting you compose your queries using tagged template literals, also to avoid sql injection and unsafe query creation. Did you read the beginning of the README.md, specifically https://github.com/porsager/postgres#await-sql---result ? Do you have any recommendations for how you think it could be better explained? I'm sorry to hear yo…