I using pg-promise with express 4 on node 8.2.0.
Inside that I want to concatenate where
condition.
But, I couldn't find that way. Please help me.
I expect this.
let ids = [10, 20, 30]
db.query('SELECT * FROM table WHERE id = {something-way}', ids)
=> I expect to execute query like a SELECT * FROM table WHERE id = 10 & id = 20 & id = 30;
Question
Can I make query like it with pg-promise's methods? Or I must concatenate string?
Please lend me your wisdom.
It depends on the logic of your
WHERE
clause.If the logic is to select all records where
id
is one of the values, then you can use:csv
modifier supported by pg-promise, in combination with theWHERE IN
clause:And if it is something else, then again, it depends on the logic, which you would need to clarify in your question.