Skip to content

Recommended way to use ANY? #907

Answered by vitaly-t
mmkal asked this question in Q&A
Jan 27, 2024 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

In your code, you are making the same mistake as here and here.

Proper usage for CSV filter:

await db.query("SELECT * FROM mytable WHERE id = ANY($1:csv)", [req.body.ids])

or

await db.query("SELECT * FROM mytable WHERE id = ANY(${ids:csv})", req.body)

or

await db.query("SELECT * FROM mytable WHERE id = ANY(${body.ids:csv})", req)

But if you want an ARRAY syntax there, then simply omit the :csv part.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mmkal
Comment options

Comment options

You must be logged in to vote
1 reply
@mmkal
Comment options

Answer selected by mmkal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants