title: node-postgres: how to execute "WHERE col IN (<dynamic value list>)" query?
body: <p>I'm trying to execute a query like this:</p>
  
  <pre><code>SELECT * FROM table WHERE id IN (1,2,3,4)
  </code></pre>
  
  <p>The problem is that the list of ids I want to filter against is not constant and needs to be different at every execution. I would also need to escape the ids, because they might come from untrusted sources, though I would actually escape anything that goes in a query regardless of the trustworthiness of the source.</p>
  
  <p>node-postgres appears to work exclusively with bound parameters: <code>client.query('SELECT * FROM table WHERE id = $1', [ id ])</code>; this will work if I had a known number of values (<code>client.query('SELECT * FROM table WHERE id IN ($1, $2, $3)', [ id1, id2, id3 ])</code>), but will not work with an array directly: <code>client.query('SELECT * FROM table WHERE id IN ($1)', [ arrayOfIds ])</code>, as there does not seem to be any special handling of array parameters.</p>
  
  <p>Building the query template dynamically according to the number of items in the array and expanding the ids array into the query parameters array (which in my actual case also contains other parameters besides the list of ids) seems unreasonably burdensome. Hard-coding the list of ids in the query template seems not viable either, as node-postgres does not provide any value escaping methods.</p>
  
  <p>This seems like a very common use-case, so my guess is that I'm actually overlooking something, and not that it is not possible to use the common <code>IN (values)</code> SQL operator with node-postgres.</p>
  
  <p>If anybody has solved this problem in a more elegant manner than those I listed above, or if I'm really missing something about node-postgres, please help.</p>