Hi guys, quick question ? I'm working on sorting e...
# orm-help
t
Hi guys, quick question ? I'm working on sorting endpoint and I'm using orderBy property, now I'm wondering how can I make it dynamic with typescript? To be more specific I'm wondering how can I make order field based on url query params?
r
Can you share the implementation that you have with the types?
t
I've basically copied required type from index.d.ts, but still doesn't work
Here's how it looks now:
Copy code
let sort_by: Type = <URL_QUERY_SORT_PARAM_VALUE>

orderBy: [
 {
  sort_by: 'asc' | 'desc',
 }
]
but sort_by is not property of type because it's custom value that represents field
r
It should be:
Copy code
orderBy: [
 {
  [sort_by]: 'asc' | 'desc',
 }
]
t
Thank you Ryan, it solved my issue, cheers!
👍 1