-
-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE]: Ability to specify selected fields dynamically #948
Comments
The selection passed to select is too wide, you could select whatever you want from the database. like count, max, all kinds of functions, etc. |
The trick is actually the "partial" generic parameter. That needs to exists somewhere for the inference to work. That's why type casting is needed. I think we can close this issue and if you think we could expose a type helper for something like this, please create a new one with your idea. I even went ahead and extended my last example to accept extra properties with proper types. See here |
Hi, |
The types changed a little bit in the last release. You actually need to use |
Thanks a lot... Here is a link for anyone who would be looking for the same thing: I had also published a post in the help section of Discord. I will answer myself by pointing to your solution and my slight change. |
Dynamic selection is "impossible" once you try to do joins. I have tried for hours, even with type casting. EDIT: I did find a way that is not fully dynamic by creating a fixed set of preset options and type casting... but that is not good for the long term. |
@mjbergman92 , found a way. See #3560 (comment) |
Describe what you want
I have a model on my project that fetching users from the database. Each time I need different set of fields and I would like to define a function with generics so only the exact fields I asked for will be return:
And then I can ask only for the fields I want:
I encounter 2 problems when trying to implement this:
P
. I'm looking for something likeP extends SelectedFields<typeof users>
Any help will be appreciated.
The text was updated successfully, but these errors were encountered: