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
You could create a View, then you could filter on that View with the js sdk
how?
it need to be dynamic with generic parameters
Your choices are rpc or view. The .or filter only works on one schema/table.
Give us the simplest example schema of what you're trying to do, and maybe we can help exactly
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
Ok, what is the exact query you're trying to do?
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'})
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
but how do I it generic as the query I sent before?
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()