Search.../

queryGroupMembers( )

Retrieves a list of up to 100 group members, given the provided paging, sorting and filtering.

Description

Creates a query to retrieve a list of group members.

Note: For SECRET groups, only site admins, group admins, and group members can query group members.

The queryGroupMembers() function builds a query to retrieve a list of all group members, and returns a GroupMembersQueryBuilder object.

The returned object contains the query definition which is typically used to run the query using the find() function.

You can refine the query by chaining GroupMembersQueryBuilder functions onto the query. GroupMembersQueryBuilder functions enable you to sort, filter, and control the results that queryMembers() returns.

queryGroupMembers() runs with these GroupMembersQueryBuilder defaults, which you can override:

The following GroupMembersQueryBuilder functions are supported for queryGroupMembers(). For a full description of the Members object, see the object returned for the items property in GroupMembersQueryResult.

PropertySupported Filters & Sorting
roleeq(), ne()
joinedDateascending(), descending()
PROPERTYSUPPORTED FILTERS & SORTING
roleeq(),ne(),exists(),in(),hasSome(),ascending(),descending()
joinedDateascending(),descending()
Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function queryGroupMembers(groupId: string): MembersQueryBuilder

queryGroupMembers Parameters

NAME
TYPE
DESCRIPTION
groupId
string

Group ID.

Returns

Was this helpful?

Query members of a group

Copy Code
1
2import { members } from 'wix-groups-v2';
3
4export function myQueryGroupMembersFunction() {
5 return members.queryGroupMembers()
6 .find()
7 .then((queryResults) => {
8 const items = results.items;
9 const firstItem = items[0];
10 const pageSize = results.pageSize;
11 const totalPages = results.totalPages;
12 const totalCount = results.totalCount;
13 const currentPage = results.currentPage();
14 const next = results.next();
15 const previous = results.prev();
16 const hasNext = results.hasNext();
17 const hasPrev = results.hasPrev();
18 const length = results.length;
19
20 return items;
21 })
22 .catch((error) => {
23 console.error(error);
24 });
25}
26
27/* Returns items:
28 * [
29 * {
30 * "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300"
31 * "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050"
32 * "role": {"value": "ADMIN"}
33 * },
34 * {
35 * "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300"
36 * "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
37 * "role": {"value": "MEMBER"}
38 * }
39 * ]
40 */