OR condition on different referencedTable(s) #29616
-
DescripitionSupabase js library allow a user to match at least on filter but I don't find any way to have conditions A and B with A that is a main table and B a referenced table. In fact, if I set the option "referencedTable", the option is applied to all the conditions described by the .or filter. It could be very nice if the "referencedTable" option could be an array, or a string, that matches the conditions length, so we can apply the option differently over the single conditions. ExampleSay we have master table as (id, title, owner) and joined table (1:N relation) as (id, master_id, note) query.or('owner.eq.1,master_id.in.(4,5,6)', {
referencedTable: "master_table,joined_table"
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, I have the same question: Say I have 2 tables,
In the doc, it only teaches how to deal with one referenced table: // Fetch all kids' name: who is in Grade 1 OR whose father is older than 30.
.from("kids")
.select('''
name,
father:father_id!inner(age),
''')
.or('grade.eq.1,age.gt.30', referencedTable: 'father_id') But what I wanna fetch is: all kids' name whose father is older than 30 OR mother is younger than 40. // Fetch all kids' name whose father is older than 30 OR mother is younger than 40.
.from("kids")
.select('''
name,
father:father_id!inner(age),
mother:mother_id!inner(age),
''')
.or('age.gt.30,age.lt.40', referencedTable: 'father_id, mother_id') // does not work Neither PostgREST API doc nor Supabase Flutter doc gave me further hints. At the time I was submitting a new discussion, it reminded me to search similar ones. I found your discussion, and another answered one
It is hard to accept the reality that I am really tired after hours of googling and trying. Next time I will come to this discussion area and search. (Seems Google did not index everything here) |
Beta Was this translation helpful? Give feedback.
-
Thank you @a6z6 |
Beta Was this translation helpful? Give feedback.
Hi, I have the same question:
Say I have 2 tables,
parents
andkids
.In the doc, it only teaches how to deal with one referenced table:
Say I wanna fetch all kids' name: who is in Grade 1 OR whose father is older than 30.
But what I wanna fetch is: all kids' name whose father is older than 30 OR mother is younger than 40.
// Fetch all kids' name whose father is older than 30 OR m…