Kosh
08/07/2021, 1:53 PM.select(
"*, following_user:follower(id, username, profile_picture, follower_count:friends.following(count)), "
"follower_user:following(id, username, profile_picture, follower_count:friends.following(count))",
)
#motherofnestingburggraf
08/07/2021, 2:55 PMsupabase.select
call here so I can see the context?burggraf
08/07/2021, 2:56 PMfriends.following(count)
refer to? Is count
a field or the SQL keyword count
, as in 'select count(*) from table'?Kosh
08/07/2021, 2:56 PMfinal response = await _supabase.client
.from(FRIENDS_DB)
.select(
"*, following_user:follower(id, username, profile_picture, follower_count:friends.following(count)), "
"follower_user:following(id, username, profile_picture, follower_count:friends.following(count))",
)
.eq('following', uid)
.paged(page)
.execute();
get my followings
final response = await _supabase.client
.from(FRIENDS_DB)
.select(
"*, follower_user:follower(id, username, profile_picture, follower_count:friends.following(count)), "
"following_user:following(id, username, profile_picture, follower_count:friends.following(count))",
)
.eq('follower', uid)
.paged(page)
.execute();
Kosh
08/07/2021, 2:57 PMcount
as in select count(*)
Kosh
08/07/2021, 2:58 PMfinal response = await _supabase.client
.from(USERS_DB)
.select('*, ' +
'following_count:friends.follower(count), follower_count:friends.following(count),' +
'challenges_count:challenges.receiver_id(count)')
.eq("id", uid)
.eq("challenges_count.challenge_state", ChallengeModel.APPROVED)
.execute();
as you can see, challenges_count
even has a conditionburggraf
08/07/2021, 2:58 PMChallengModel.APPROVED
?Kosh
08/07/2021, 2:59 PM.name
so I went ahead with final stringsburggraf
08/07/2021, 2:59 PMburggraf
08/07/2021, 3:00 PMburggraf
08/07/2021, 3:01 PMKosh
08/07/2021, 3:01 PMcreate table users
(
id uuid not null
constraint users_pkey
primary key
constraint users_id_fkey
references auth.users
on delete cascade,
username varchar(200) not null,
locale varchar(30) not null,
profile_picture text,
created_at timestamp with time zone default timezone('utc'::text, now()) not null
);
friends table
create table friends
(
follower uuid not null
constraint friends_follower_fkey
references users
on delete cascade,
following uuid not null
constraint friends_following_fkey
references users
on delete cascade,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
constraint friends_pkey
primary key (follower, following)
);
burggraf
08/07/2021, 3:02 PMcount
in Postgrest. I'll need to go back and see what other cool things it can do.burggraf
08/07/2021, 3:02 PMKosh
08/07/2021, 3:02 PMburggraf
08/07/2021, 3:03 PMKosh
08/07/2021, 3:03 PMburggraf
08/07/2021, 3:03 PMKosh
08/07/2021, 3:04 PMburggraf
08/07/2021, 3:04 PMburggraf
08/07/2021, 3:04 PMKosh
08/07/2021, 3:05 PMcount/selection
its fine to do it on client side.burggraf
08/07/2021, 3:05 PMKosh
08/07/2021, 3:06 PMburggraf
08/07/2021, 3:06 PMburggraf
08/07/2021, 3:06 PMKosh
08/07/2021, 3:06 PM