I want to create a “prepared statement” in postgres using the node-postgres module. I want to create it without binding to parameters, because the binding will be done in a loop.
In the documentation, I read:
query(object config, optional function callback) : Query
If _text_ and _name_ are provided within the config, the query will result in the creation of a prepared statement.
I tried
client.query({"name":"mystatement", "text":"select id from mytable where id=$1"});
but when I try to pass only the text and names in the config object, I get an exception:
A (translated) message is a required parameter 0, but a prepared statement expects 1
Is there something I am missing? How to create / prepare an instruction without reference to a certain value in order to avoid repeated preparation of an instruction at each step of the cycle?
source
share