How would you query not exist from a different table #2417
-
|
Hi there, I just recently, decided its time to ditch Firebase and use supabase for alot of reasons and I already started the migration, however I suck upon an issue with querying the database where i would like to list users if I didn't block them, that's simple if I use the built in query Now I'm kinda stuck cuz of lack of documentation to how can I do achieve such query using the dart client or even the js client. I tried the below: but I got Also tried: but that returns users and their blocks Any help will be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Hey @k0shk0sh, You can create function of your query and call it through supabase rpc. create or replace function unblocked_users(name text) returns users as $$
select * from users as t1 where LOWER(t1.name) like LOWER('%' || name || '%')
and not exists (select * from blocks as t2 where t2.blocked_id = t1.id)
$$ language sql;const { data, error } = await supabase
.rpc('unblocked_users')
// with rpc, you can also use select() or other filters like eq() |
Beta Was this translation helpful? Give feedback.
Hey @k0shk0sh,
You can create function of your query and call it through supabase rpc.