Is it possible to use a parameterized query with an IN operator?
I'm imagining something like:
const text = 'SELECT * FROM tbl WHERE col1 IN ($1) AND col2 = $2';
const values = [[1, 2, 3], 1000000];
Currently I'm injecting the values for IN using a string template:
const text = `SELECT * FROM tbl WHERE col1 IN (${[1, 2, 3].join(', ')}) AND col2 = $1`;
const values = [1000000];
Use an array parameter. (https://github.com/brianc/node-postgres/issues/82#issuecomment-18756081, https://github.com/brianc/node-postgres/issues/129#issuecomment-48633017, #623)
const text = 'SELECT * FROM tbl WHERE col1 = ANY ($1) AND col2 = $2';
const values = [[1, 2, 3], 1000000];
Most helpful comment
Use an array parameter. (https://github.com/brianc/node-postgres/issues/82#issuecomment-18756081, https://github.com/brianc/node-postgres/issues/129#issuecomment-48633017, #623)