i have an rpc call that returns a json object, the...
# help
u
i have an rpc call that returns a json object, the TS types seem to force that an rpc call will return an array of whatever is given to the generic? is there something i'm doing wrong or is there a way around this?
Copy code
js
const { data } = await supabase.rpc<Record<string, number>>('comments_stats')
data here is
Record<string, number>[] | null
n
Hello @(d,f,g)=> 🥁! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
🆕 TS type for RPC calls is always an array?
u
workaround for now is to
return data as unknown as Record<string, number>
but it would be ideal not to enforce that an rpc call always returns an array
n
🆕 order by on a stored precedure?
🆕 TS type for RPC calls is always an array?