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. However, if the suppressAuth option is set to true, all permissions are overwritten, and all site members (including non-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()

Syntax

function queryGroupMembers(): GroupMembersQueryBuilder

queryGroupMembers Parameters

This function does not take any parameters.

Returns

A GroupMembersQueryBuilder object that contains the refined query.

Was this helpful?

Query members of a group

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