I have a tag area where 0...N tags can be chosen. The tag area gives a comma separated list which will then be sent to the server for further processing. For example, the tag csv-list can look like this:
var taglist = ['important', 'less important']
I create an array out of it for it to be processed by LIKE ANY.
var taglistArray = pgp.as.array(taglist);
There is a possible way with LIKE ANY but I could not get it to work.
select * from $1:name WHERE importance LIKE ANY $4:list
...
['tablename', field2, field3, taglistArray]
error: syntax error at or near "'array[''important'',''less important'']'"
There seem to be several issues if the tag area is empty (hence the query should return everything and not nothing) and the ability to query a list instead of just one keyword.
How can a list of tags be translated into a SQL query in the best way using pg-promise?