It looks like you may have been close based on your comment to @ebohlman’s answer. You can use WHERE id = ANY($1::int[])
. PostgreSQL will convert the array to the type the parameter is cast to in $1::int[]
. So here’s a contrived example that works for me:
var ids = [1,3,4];
var q = client.query('SELECT Id FROM MyTable WHERE Id = ANY($1::int[])',[ids]);
q.on('row', function(row) {
console.log(row);
})
// outputs: { id: 1 }
// { id: 3 }
// { id: 4 }