data with join and logical 'OR'

Hi there, I'm trying to do a join with logical OR on foreign table with js SDK. I saw on this post https://stackoverflow.com/questions/70699495/supabase-filter-data-with-join-and-logical-or that says it is not possible as for now. The problem is that I don't want to use rpc because I want to build a query with generic columns and filters. Any suggestions?
Stack Overflow
Supabase: Filter data with join and logical 'OR'
I'm using Supabase as a database and trying to implement a full-text search. My example setup is quite simple, I have two tables: items +----+-----------+-----------------+ | id | name |
10 Replies
jdgamble555
jdgamble5553y ago
You could create a View, then you could filter on that View with the js sdk
Tal Mikey
Tal MikeyOP3y ago
how? it need to be dynamic with generic parameters
garyaustin
garyaustin3y ago
Your choices are rpc or view. The .or filter only works on one schema/table.
jdgamble555
jdgamble5553y ago
Give us the simplest example schema of what you're trying to do, and maybe we can help exactly
Tal Mikey
Tal MikeyOP3y ago
I have lessons schema with teacher_id and teachers schema. I query the lessons and display them on table in html. I have a general search input that if I search for any input I want it to search in both parent and child table. The reason I say it's dynamic is because I reuse this table for serveral templates with other parent-child tables
jdgamble555
jdgamble5553y ago
Ok, what is the exact query you're trying to do?
Tal Mikey
Tal MikeyOP3y ago
await supabase.from('lessons').select('name,day,teacher:teachers!inner(firstName,lastName)').or('name.like.%a%, day.like.%a%).or('firstName.like.%a%, lastName.like.%a%, {foreignTable: 'teacher'})
jdgamble555
jdgamble5553y ago
If you're specifically needing this for searching, I highly recommend an rpc function anyway... you will have more control over how you want your searching to work
Tal Mikey
Tal MikeyOP3y ago
but how do I it generic as the query I sent before?
jdgamble555
jdgamble5553y ago
you query it in sql with whatever input you want your rpc function to have - https://supabase.com/docs/reference/javascript/rpc
Postgres functions: rpc()
Postgres functions: rpc()

Did you find this page helpful?