Search.../

queryMemberships( )

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

Description

Creates a query to retrieve a list of memberships.

Note: Only site admins can query a site member's memberships. Site members can query their memberships. However, if the suppressAuth option is set to true, all permissions are overwritten, and all site members (including non-group members) can query a site member's memberships.

The queryMemberships() function builds a query to retrieve a list of all memberships, and returns a MembershipsQueryBuilder 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 queryMemberships() returns.

The results of the queryMemberships() function are sorted by groupId in descending order.

queryMemberships() runs with this GroupMembersQueryBuilder default, which you can override:

The following GroupMembersQueryBuilder functions are supported for queryMemberships(). For a full description of the Memberships object, see the object returned for the items property in MembershipsQueryResult.

PropertySupported Filters & Sorting
statuseq(), ne()
roleeq(), ne()

Syntax

function queryMemberships(): GroupMembersQueryBuilder

queryMemberships Parameters

This function does not take any parameters.

Returns

A GroupMembersQueryBuilder object that contains the refined query.

Was this helpful?

Query a site member's memberships

Copy Code
1import { members } from 'wix-groups-backend';
2
3export function myQueryMembershipsFunction() {
4 return members.queryMemberships()
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 * "groupId": "937cd3db-e9be-4980-93c1-a6d767a11050"
30 * "status": "JOINED"
31 * "role": "ADMIN"
32 * },
33 * {
34 * "groupId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
35 * "status": "PENDING"
36 * "role": "MEMBER"
37 * }
38 * ]
39 */