For cases like this, I use pl/pgsql functions and dynamic queries. Dynamic queries take extra care and aren't the most pleasant things to write, but they can handle the GET /things with 10 parameters endpoints quite well.
> what do you do when implementing a REST endpoint like GET /things where the user can give any number of 10 query parameters to filter the result?
https://www.elastic.co/guide/en/elasticsearch/reference/curr...
Re:The Art of PostgreSQL
by spiderxxxx on Wednesday August 21, 2019 @06:07PM
(#20762397)
You do "or <parameter> IS NULL". It makes the query plan uncacheable or requiring a godly cache, but it's fine for searches.
I tend to do it the same way, but how do you deal with the lack of a query builder when you truly need to build a query on the fly? For example, what do you do when implementing a REST endpoint like GET /things where the user can give any number of 10 query parameters to filter the result?