【发布时间】:2012-09-02 03:18:35
【问题描述】:
我想使用 node-postgres 模块在 postgres 中创建一个“准备好的语句”。我想创建它而不将其绑定到参数,因为绑定将在循环中进行。
在documentation 我读到:
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.
我试过了
client.query({"name":"mystatement", "text":"select id from mytable where id=$1"});
但是当我尝试只传递配置对象中的文本和名称键时,我得到一个异常:
(已翻译)消息绑定了 0 个参数,但准备好的语句需要 1 个
我有什么遗漏吗?如何在不将其绑定到特定值的情况下创建/准备语句以避免在循环的每个步骤中重新准备语句?
【问题讨论】:
标签: node.js node-postgres