I am having trouble executing this query
var insurers = [];
var valid_insurer_query = plv8.execute('select * from table_name where row_id IN $1', [insurers])
It is giving syntax error
Error: syntax error at or near "$1"
It works fine if I use the query
var valid_insurer_query = plv8.execute('select * from table_name where row_id = $1', [insurer]) // here insurer is some entry from insurers.
I think it is creating trouble because psql query is unable to use javascript array as list. But I don't know how can I fix this issue ? Can anyone suggest some solution ? Can anyone share an example on how to use IN query in plv8 ?
I don't use plv8, but IN works with lists and lists can't be stored in parameters. What you appear to have is an array. For arrays, you use:
=ANY($1)