在 .query 的字符串中,美元符号 ('$') 是什么意思?

What does the dollar sign ('$') mean when in the string to .query?

这个语句中的$符号是什么意思:

// SQL Query > Update Data
client.query('UPDATE items SET text=(), complete=() WHERE id=()',
[data.text, data.complete, id]);

在那种情况下,它被普遍称为 "placeholder"。您从 blog entry 中获得了该代码。您可以看到 client 是在 pg.connect

的回调中定义的
pg.connect(connectionString, (err, client, done) => {

在该博客条目中查找,pg 在这里定义

const pg = require('pg');

您总是可以通过 quick search. In this case though the blog openly says they're using node-postgres 找出 npm-installed 模块名称解析的内容。这在哪个文件下,

参数化表示接受一个参数。该参数的位置由 "placeholder" 定义,如 $ 所指定。这样做的目的通常是为了节省 规划 的时间并避免 SQL 注入攻击。