postgres icon indicating copy to clipboard operation
postgres copied to clipboard

How to concatinate multiple partial statements

Open NPrada opened this issue 10 months ago • 0 comments

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

NPrada avatar Apr 15 '24 19:04 NPrada