The syntax for a parameterized query in postgres is $[index of target parameter]. However, when dynamically building SQL queries keeping track of indices can be a bit messy and requires us to do things like sql += 'foo = $' + (params.length + 1). This leads to many opportunities for errors while writing the code and makes it more difficult to reason about.
To fix this, some middleware can be added before larkin.queryPg that automatically substitutes the correct indices.
The syntax for a parameterized query in postgres is
$[index of target parameter]
. However, when dynamically building SQL queries keeping track of indices can be a bit messy and requires us to do things likesql += 'foo = $' + (params.length + 1)
. This leads to many opportunities for errors while writing the code and makes it more difficult to reason about.To fix this, some middleware can be added before
larkin.queryPg
that automatically substitutes the correct indices.