1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Return the number of friends of a user

This commit is contained in:
2020-06-01 10:00:58 +02:00
parent 9d4b60f0ff
commit a5dab7e312
2 changed files with 17 additions and 0 deletions

View File

@ -15,4 +15,12 @@ pub fn are_friend(user_one: UserID, user_two: UserID) -> ResultBoxError<bool> {
.cond_i64("ID_personne", user_one)
.cond_i64("ID_amis", user_two)
.cond_i64("actif", 1))? > 0)
}
/// Count the number of friends of a user
pub fn count_friends(user_id: UserID) -> ResultBoxError<usize> {
QueryInfo::new(FRIENDS_TABLE)
.cond_i64("ID_amis", user_id)
.cond_u32("actif", 1)
.exec_count()
}