I used my parameters in my SQL query when preparing it for practical reasons, for example, in php with PDO.
Can I use named parameters with the node-postgres module?
Currently, I have seen many examples and documents on the Internet showing such queries:
client.query("SELECT * FROM foo WHERE id = $1 AND color = $2", [22, 'blue']);
But is that also correct?
client.query("SELECT * FROM foo WHERE id = :id AND color = :color", {id: 22, color: 'blue'});
or
client.query("SELECT * FROM foo WHERE id = ? AND color = ?", [22, 'blue']);
I ask about this because of the numbered parameter $n, which does not help me in the case of dynamic queries.
source
share