Dynamic query parts based on user input
Based on certain user input (REST API), I need to filter and/or sort by provided fields.
This could mean that some joins need to be added as well.
The fields to filter and sort are not always a 1-1 mapping to a database column, the names can deviate.
I came of with a mapping like:
and this is an example case of how to use it:
above is just for illustration, in fact the call will be something like:
and this works!
But the thing is it depends havily on the
sql
tag, so none is typesafe unfortuantely.
Kylesy itself does a tremendous job about type safety.
Is there a way to make that queryFields
with the joins type safe? e.g. with helper methods?3 Replies
e.g. I did a similar experiment with Drizzle ORM, and there I did something like:
which if fully type safe.
Drizzle is just so much better in pretty much everything. I really think you should select it.
Is that a serious answer, or being sarcastic?
Nevertheless, I'm looking to see if this is possible with Kylesy or not...