What does the $
sign mean in this statement:
// SQL Query > Update Data
client.query('UPDATE items SET text=($1), complete=($2) WHERE id=($3)',
[data.text, data.complete, id]);
Pretty universally in that context it's called a "placeholder". You got that code from this blog entry. You can see there that client
is defined above in the callback to pg.connect
,
pg.connect(connectionString, (err, client, done) => {
Looking up in that blog entry, pg
is defined here
const pg = require('pg');
You can always find out what an npm-installed module name resolves to by doing a quick search. In this case though the blog openly says they're using node-postgres. Which documents this under,
Paramaterized means accepting of a parameter. That parameter's placement is defined with a "placeholder" as specified with $
. The purpose of this is often to save time in planning and to avert SQL Injection attacks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With