select multiple joins
how do you do multiple joins with select on useTable when using supabase?
8 Replies
Hi @fuddlesworth. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine, you can handle multiple joins using the
meta
property in the useTable
hook when using Supabase. The meta
property is used to pass additional information that can be read by data provider methods.
For example, if you have a many-to-many relationship like movies <-> categories_movies <-> categories
, you can get the categories
data of a user using the meta
property as shown below:
In this example, the select
value in the meta
object is used to perform the relational database operation. The select
property is used internally by the Supabase data provider methods.
You can find more details in the Supabase data provider documentation (https://refine.dev/docs/packages/documentation/data-providers/supabase).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@205390473609609217> kapa.ai is still learning and improving, please let us how it did by reacting below
genetic-orange•15mo ago
@kapa.ai how would i join categories to another table in that example
Let me check the knowledge base for you. One moment! :books:
----------------------
To join
categories
to another table, you would use the select
property in the meta
object of the useTable
hook. The select
property is used to perform relational database operations in the Supabase data provider.
Here's an example of how you might join categories
to a posts
table:
In this example, the select
property is set to "*, categories(name)"
, which means it will select all fields from the posts
table and the name
field from the categories
table. The categories
table is joined to the posts
table through the categories
field in the posts
table.
You can find more details in the Supabase data provider documentation (https://refine.dev/docs/packages/documentation/data-providers/supabase).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@205390473609609217> kapa.ai is still learning and improving, please let us how it did by reacting below
genetic-orange•15mo ago
@kapa.ai no, how would i join categories to movies and another table to categories
Let me check the knowledge base for you. One moment! :books:
----------------------
To join
categories
to movies
and another table (let's say tags
) to categories
, you would use the select
property in the meta
object of the useTable
hook. The select
property is used to perform relational database operations in the Supabase data provider.
Here's an example of how you might join these tables:
In this example, the select
property is set to "*, categories(name, tags(name))"
, which means it will select all fields from the movies
table, the name
field from the categories
table, and the name
field from the tags
table. The categories
table is joined to the movies
table through the categories
field in the movies
table, and the tags
table is joined to the categories
table through the tags
field in the categories
table.
You can find more details in the Supabase data provider documentation (https://refine.dev/docs/packages/documentation/data-providers/supabase).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@205390473609609217> kapa.ai is still learning and improving, please let us how it did by reacting below