Using pg
in my NodeJS application I would like to be able to pass an array to a function so that I can use the IN
statement as part of my query
Example
async function myMethod(array) {
// array looks like [ '83', '82', '54', '55', '79' ] for example
let response;
try {
response = await pool.query("SELECT * FROM fixtures WHERE id IN($1)", [array]);
} catch (e) {
console.log(e);
}
return response.rows;
}
I get an error
{ error: invalid input syntax for integer: "{"83","82","54","55","79"}"
How do I go about structuring my query here please?