I have created clients, restaurants and favorites tables in supabase and linked them using foreign keys, I want to list a client's favorite restaurant if any and also insert favorite restaurants when the client clicks on the favorite icon.
The created schema looks like this
clients
client_id uuid(pk),
name text,
email text,
avatar text,
points float4,
favorite_id uuid(fk),
restaurants
restaurant_id uuid(pk),
name text,
description text,
logo text,
location text,
menu json,
favorites
favorite_id uuid(pk),
created_at now(),
client_id uuid(fk),
restaurant_id uuid(fk),
For inserting a favorite restaurant to a client
final res = await supabase.client
.from('favorites')
.insert({
'client_id': user.id,
'restaurant_id': res.id
})
.execute();
///Which works fine
For querying a favorite restaurant of a client
final res = await supabase.client
.from('restaurants')
.select('*, favorites!inner(*)')
.eq('client_id ', user.id);
///Doesn't work at all`