get
Groups
Count
@Query(value = "SELECT COUNT(*) FROM " + GROUPS_KEY + " AS groups LEFT JOIN " + GROUP_MEMBERS_TABLE +
" ON groups." + IDENTIFIER_KEY + " = group_members." + GROUP_MEMBER_KEY + " WHERE " +
GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " +
"groups." + NAME_KEY + " LIKE %:" + NAME_KEY + "%" +
" AND (" +
"COALESCE(:" + ROLES_FILTER_KEY + ") IS NULL" +
" OR " + GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" +
") AND " +
GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" + " AND " +
GROUP_MEMBERS_TABLE + "." + INVITATION_STATUS_KEY + " = " + "'JOINED'",
nativeQuery = true
)
Method to execute the query to count the total groups where the user is a GroupMember
Return
the total numbers of the groups
Parameters
userId
The user identifier
name
The name of the group to use as filter
roles
The role values to use as filter