postgres
postgres copied to clipboard
How to concatinate multiple partial statements
I have a dynamic array of conditions
const conditions = [
sql`age > 1`,
sql`height < 170`,
sql`hair_color = 'red'`
]
I would like to join al of these conditions with and AND and create a runnable query that looks like this:
SELECT * FROM humans WHERE age > 1 AND height < 170 AND hair_color = 'red
What is the correct way to go about it? Is it possible using this library, i could not figure it our reading the docs