Search.../

queryGuests( )

Creates a query to retrieve a list of guests.

Description

The queryGuests() function builds a query to retrieve a list of guests and returns a GuestsQueryBuilder 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 GuestsQueryBuilder functions onto the query. GuestsQueryBuilder functions enable you to sort, filter, and control the results that queryGuests.find() returns.

The query runs with the following GuestsQueryBuilder defaults that you can override:

The functions that are chained to queryGuests() are applied in the order they are called. For example, if you apply ascending ('_createdDate') and then descending ('_updatedDate'), the results are sorted first by the created date and then, if there are multiple results with the same date, the items are sorted by the updated date.

The table below shows which GuestsQueryBuilder functions are supported for queryGuests(). You can only use one filter function for each property. Only the first filter will work if a property is used in more than one filter.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),in(),exists()
eventIdeq(),ne(),in(),exists()
rsvpIdeq(),ne(),in(),exists()
orderNumbereq(),ne(),in(),exists()
ticketNumbereq(),ne(),in(),exists()
ticketsexists()
contactIdeq(),ne(),in(),exists()
guestDetails.checkedIneq(),ne(),exists()
attendanceStatuseq(),ne(),in()
secondaryLanguageCodeeq(),ne(),in(),exists()
_createdDateeq(),ne(),lt(),le(),gt(),ge(),in(),exists(),ascending(),descending()
_updatedDateeq(),ne(),lt(),le(),gt(),ge(),in(),exists(),ascending(),descending()
attendanceStatusUpdatedDateeq(),ne(),lt(),le(),gt(),ge(),in(),exists(),ascending(),descending()
memberIdeq(),ne(),in(),exists()
guestTypeeq(),ne(),in()
Admin Method

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

Syntax

function queryGuests(): GuestsQueryBuilder

queryGuests Parameters

This function does not take any parameters.

Returns

Return Type:

Was this helpful?

Retrieve all RSVP-type guests and sort by _createdDate

Copy Code
1import { guests } from "wix-events.v2";
2
3async function queryGuests() {
4 try {
5 const result = await guests.queryGuests()
6 .eq("guestType", "RSVP")
7 .ascending("_createdDate")
8 .find()
9 return result;
10 } catch (error) {
11 console.error(error);
12 // Handle the error
13 }
14 }
15
16/* RSVP guests info
17{
18 [
19 {
20 "_id": "be050b90-5915-4888-83eb-f39bb4ff4b94",
21 "eventId": "b189cf8b-a61f-443b-95bb-d9e88af0a277",
22 "rsvpId": "c83047ff-fae6-420b-a1d6-5ad2be59cb96",
23 "tickets": [],
24 "contactId": "023b6403-17e6-42dc-b475-a5ae6c2b8df4",
25 "attendanceStatus": "ATTENDING",
26 "_createdDate": "2023-01-27T12:35:46.749Z",
27 "_updatedDate": "2023-01-27T12:35:46.749Z",
28 "attendanceStatusUpdatedDate": "2023-01-27T12:35:46.000Z",
29 "guestType": "RSVP"
30 },
31 {
32 "_id": "2caffa73-6c17-4797-b2df-5a7fc78b21d7",
33 "eventId": "b189cf8b-a61f-443b-95bb-d9e88af0a277",
34 "rsvpId": "1480c6f1-a425-4e05-89c0-44e5d27136cd",
35 "tickets": [],
36 "contactId": "804e6beb-365f-4992-8e35-8f12788e62fa",
37 "attendanceStatus": "ATTENDING",
38 "_createdDate": "2023-01-27T12:54:26.558Z",
39 "_updatedDate": "2023-01-27T12:54:26.558Z",
40 "attendanceStatusUpdatedDate": "2023-01-27T12:54:26.000Z",
41 "guestType": "RSVP"
42 }
43]
44} */
Retrieve all buyer-type guests from a specified event

Copy Code
1import { guests } from "wix-events.v2";
2
3async function queryGuests() {
4 try {
5 const result = await guests.queryGuests()
6 .eq("guestType", "BUYER")
7 .eq("eventId", "9d720f99-1b5a-4141-9877-d32985391e18")
8 .find();
9 return result;
10 } catch (error) {
11 console.error(error);
12 // Handle the error
13 }
14 }
15/*Returns all found buyers
16{
17 "_items": [
18 {
19 "_id": "708aaa09-c34a-431b-919f-6db7dadde381",
20 "eventId": "9d720f99-1b5a-4141-9877-d32985391e18",
21 "orderNumber": "2T90-H5P6-17J",
22 "tickets": [
23 {
24 "number": "2T90-H5P6-17J1P",
25 "definitionId": "13fba1ae-657f-47d0-8759-fd8df5a94e65",
26 "name": "Participant ticket"
27 },
28 {
29 "number": "2T90-H5P6-17J1Q",
30 "definitionId": "13fba1ae-657f-47d0-8759-fd8df5a94e65",
31 "name": "Participant ticket"
32 }
33 ],
34 "contactId": "023b6403-17e6-42dc-b475-a5ae6c2b8df4",
35 "attendanceStatus": "ATTENDING",
36 "_createdDate": "2023-03-16T12:49:34.103Z",
37 "_updatedDate": "2023-03-16T12:49:34.119Z",
38 "attendanceStatusUpdatedDate": "2023-03-16T12:49:34.006Z",
39 "guestType": "BUYER"
40 }
41 ],
42 "_originQuery": {
43 "filterTree": {
44 "$and": [
45 {
46 "guestType": "BUYER"
47 },
48 {
49 "eventId": "9d720f99-1b5a-4141-9877-d32985391e18"
50 }
51 ]
52 },
53 "invalidArguments": [],
54 "encoder": {},
55 "transformationPaths": {},
56 "sort": [],
57 "paging": {},
58 "pagingMethod": "CURSOR",
59 "builderOptions": {
60 "cursorWithEmptyFilterAndSort": true
61 }
62 },
63 "_limit": 50,
64 "_nextCursor": "",
65 "_prevCursor": "",
66 "cursors": {
67 "next": "",
68 "prev": ""
69 }
70}
71*/
Retrieve Ticket holder-type guest and show only first one

Copy Code
1import { Permissions, webMethod } from "wix-web-module";
2import { guests } from "wix-events.v2";
3
4export const queryGuests = webMethod(Permissions.Anyone, async () => {
5 try {
6 const result = await guests.queryGuests().eq("guestType", "TICKET_HOLDER").find();
7 return result.items[0];
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12});
13
14/*Returns the first ticket holder
15{
16 "eventId": "9d720f99-1b5a-4141-9877-d32985391e18",
17 "orderNumber": "2T90-H5P6-17J",
18 "ticketNumber": "2T90-H5P6-17J1P",
19 "tickets": [],
20 "contactId": "023b6403-17e6-42dc-b475-a5ae6c2b8df4",
21 "attendanceStatus": "ATTENDING",
22 "attendanceStatusUpdatedDate": "2023-03-16T12:49:34.006Z",
23 "guestType": "TICKET_HOLDER",
24 "_id": "1a446e7a-0525-4747-87d5-e1f153e2a041",
25 "_createdDate": "2023-03-16T12:49:34.103Z",
26 "_updatedDate": "2023-03-16T12:49:34.119Z"
27}
28*/
29