Search.../

queryMembers( )

Developer Preview

Retrieves a list of up to 100 members, given the provided filters, fieldsets, sorting and paging, and returns a MembersQueryBuilder object.

Description

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 MembersQueryBuilder functions onto the query. MembersQueryBuilder functions enable you to sort, filter, and control the results that queryMembers() returns. The functions that are chained to queryMembers() are applied in the order they are called.

queryMembers() runs with the following MembersQueryBuilder defaults that you can override:

  • skip: 0
  • limit: 50

Currently supported fields for sorting:

  • profile.nickname
  • contact.firstName
  • contact.lastName
  • createdDate
  • lastLoginDate

The following MembersQueryBuilder functions are supported for the queryMembers() function. For a full description of the Locations object, see the returned for the items property in MembersQueryResult.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),exists(),in(),hasSome(),startsWith()
loginEmaileq(),ne(),exists(),in(),hasSome(),startsWith()
contact.firstNameeq(),ne(),exists(),in(),hasSome(),startsWith()
contact.lastNameeq(),ne(),exists(),in(),hasSome(),startsWith()
profile.nicknameeq(),ne(),exists(),in(),hasSome(),startsWith()
profile.slugeq(),ne(),exists(),in(),hasSome(),startsWith()
privacyStatuseq(),ne(),exists(),in(),hasSome()

Syntax

function queryMembers(options: QueryMembersOptions): MembersQueryBuilder

queryMembers Parameters

NAME
TYPE
DESCRIPTION
options
Optional
QueryMembersOptions

Query options.

Returns

Was this helpful?

Query member's with all option parameters (export from backend code)

Copy Code
1import { members } from 'wix-members.v2';
2import { webMethod, Permissions } from 'wix-web-module';
3
4/* Sample parameter values
5 * {
6 * "options": {
7 * "fieldsets": ["EXTENDED"],
8 * "search": {
9 * "expression": "John Doe"
10 * },
11 * "fields": [
12 * "loginEmail",
13 * "contact.firstName",
14 * "contact.lastName",
15 * "profile.title",
16 * "profile.nickname",
17 * "profile.slug"
18 * ]
19 * }
20 * }
21 */
22
23export const myQueryMembersFunction = webMethod(
24 Permissions.Anyone,
25 async (options) => {
26 try {
27 const siteMembers = await members.queryMembers(options).find();
28 console.log('Retrieved members:', siteMembers);
29
30 return siteMembers;
31 } catch (error) {
32 console.error(error);
33 // Handle the error
34 }
35 }
36);
37
38/* Promise resolves to:
39 * {
40 * "_items": [
41 * {
42 * "loginEmail": "newmember1@example.com",
43 * "loginEmailVerified": false,
44 * "status": "APPROVED",
45 * "contactId": "bbfa3373-9bc0-4479-9766-40e9ff4b6661",
46 * "contact": {
47 * "contactId": "bbfa3373-9bc0-4479-9766-40e9ff4b6661",
48 * "phones": [],
49 * "emails": [],
50 * "addresses": [],
51 * "customFields": {}
52 * },
53 * "profile": {
54 * "nickname": "John Doe",
55 * "slug": "newmember1"
56 * },
57 * "privacyStatus": "PUBLIC",
58 * "activityStatus": "ACTIVE",
59 * "_id": "bbfa3373-9bc0-4479-9766-40e9ff4b6661",
60 * "_createdDate": "2024-03-01T13:12:43.000Z",
61 * "_updatedDate": "2024-03-01T13:12:43.459Z"
62 * }
63 * ],
64 * "_originQuery": {
65 * "filterTree": {
66 * "$and": []
67 * },
68 * "invalidArguments": [],
69 * "encoder": {},
70 * "transformationPaths": {},
71 * "sort": [],
72 * "paging": {},
73 * "pagingMethod": "OFFSET",
74 * "builderOptions": {
75 * "cursorWithEmptyFilterAndSort": true
76 * }
77 * },
78 * "_limit": 50,
79 * "_totalCount": 1,
80 * "_offset": 0,
81 * "_tooManyToCount": false
82 * }
83 */