Dynamic Select Queries #1785
Unanswered
BigBoulard
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You probably want to look at the But if your ultimate goal is SQL you might want to look into building the JSON directly in PostgreSQL with functions like |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi mates,
I wonder how I can handle dynamic fields in a select query.
For example, in a REST API, a request like this
/GET /users?fields=id,first_name,last_name,phone,country
would trigger a query like thisselect id, first_name, last_name, phone, country from user;
and then return the appropriate data structure to create the JSON.Similarly, a request like this
/GET /users?fields=id,phone
would trigger a query like thisselect id, phone from user;
etc.I can build the query like below but I don't know how to manage the
Scan
part cause usually the fields are known beforehand.For selecting a single row, I used to do something like below but obviously this doesn't work as we don't know the requested fields beforehand...
Beta Was this translation helpful? Give feedback.
All reactions