In the documentation for fetching, under Query the same referenced table multiple times, it states an approach, which doesn't infer correct types on the resulting object.
This works and fetches the correct data, but with typescript, the types are incorrect; from and to are both typed as {}[].
Describe the improvement
I believe the documentation should mention another possible approach, which is also mentioned in the PostgREST documentation, which returns the correct data and infers the types correctly:
Here the users is the name of the foreign table from which we are querying and messages_from_fkey and messages_from_fkey are the names of the foreign key constraints.
Improve documentation
In the documentation for fetching, under
Query the same referenced table multiple times
, it states an approach, which doesn't infer correct types on the resulting object.Link
https://supabase.com/docs/reference/javascript/select
Describe the problem
The documentation states this approach
This works and fetches the correct data, but with typescript, the types are incorrect;
from
andto
are both typed as{}[]
.Describe the improvement
I believe the documentation should mention another possible approach, which is also mentioned in the PostgREST documentation, which returns the correct data and infers the types correctly:
Here the
users
is the name of the foreign table from which we are querying andmessages_from_fkey
andmessages_from_fkey
are the names of the foreign key constraints.