> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: queryGuests(options: QueryEventGuestsOptions)

# Method package: wixEventsV2

# Method menu location: wixEventsV2 --> guests --> queryGuests

# Method Link: https://dev.wix.com/docs/velo/apis/wix-events-v2/guests/query-guests.md

# Method Description:

Creates a query to retrieve a list of guests.


The `queryGuests()` function builds a query to retrieve a list of guests and returns a [GuestsQueryBuilder](https://www.wix.com/velo/reference/wix-events-v2/guests/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:

- [`skip(0)`](https://www.wix.com/velo/reference/wix-events-v2/guests/guestsquerybuilder/skipto)
- [`limit(50)`](https://www.wix.com/velo/reference/wix-events-v2/guests/guestsquerybuilder/limit)
- [`descending("_createdDate")`](https://www.wix.com/velo/reference/wix-events-v2/guests/guestsquerybuilder/descending)

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.


|PROPERTY	|SUPPORTED FILTERS & SORTING	
|:---:|:---:|
|`_id`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`eventId`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`rsvpId`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`orderNumber`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`ticketNumber`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`tickets`|[`exists()`](/guests-query-builder/exists)|
|`contactId`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`guestDetails.checkedIn`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`exists()`](/guests-query-builder/exists)|
|`attendanceStatus`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in)|
|`secondaryLanguageCode`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`_createdDate`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`lt()`](/guests-query-builder/lt),[`le()`](/guests-query-builder/le),[`gt()`](/guests-query-builder/gt),[`ge()`](/guests-query-builder/ge),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists),[`ascending()`](/guests-query-builder/ascending),[`descending()`](/guests-query-builder/descending)|
|`_updatedDate`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`lt()`](/guests-query-builder/lt),[`le()`](/guests-query-builder/le),[`gt()`](/guests-query-builder/gt),[`ge()`](/guests-query-builder/ge),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists),[`ascending()`](/guests-query-builder/ascending),[`descending()`](/guests-query-builder/descending)|
|`attendanceStatusUpdatedDate`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`lt()`](/guests-query-builder/lt),[`le()`](/guests-query-builder/le),[`gt()`](/guests-query-builder/gt),[`ge()`](/guests-query-builder/ge),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists),[`ascending()`](/guests-query-builder/ascending),[`descending()`](/guests-query-builder/descending)|
|`memberId`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in),[`exists()`](/guests-query-builder/exists)|
|`guestType`|[`eq()`](/guests-query-builder/eq),[`ne()`](/guests-query-builder/ne),[`in()`](/guests-query-builder/in)|



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Retrieve all guests (dashboard page code) 

```javascript
import { guests } from "wix-events.v2";

/* Sample options value:
 *
 * {
 *    "fields": ["GUEST_DETAILS"]
 * }
 * 
 */
  
export async function myQueryGuestsFunction(options) {
   try {
     const items = await guests.queryGuests(options)
     .find()
     console.log('Success! Guests: ', items)
     return items;
   } catch (error) {
     console.error(error);
     // Handle the error
    }
 }

/* Promise resolves to:
 * {
 * "_items": [
 *  {
 *     "eventId": "3a80a30c-643d-4b11-b38f-1150dbe7c538",
 *     "orderNumber": "2SVV-RH7C-P3D",
 *     "tickets": [],
 *     "contactId": "c64c558f-ed41-4395-b820-f8dd66c31702",
 *     "guestDetails": {
 *      "email": "johndoe@mail.com",
 *       "firstName": "John",
 *       "lastName": "Doe",
 *       "formResponse": {
 *         "inputValues": [
 *          {
 *            "inputName": "firstName",
 *             "value": "John",
 *             "values": []
 *           },
 *           {
 *             "inputName": "lastName",
 *            "value": "Doe",
 *             "values": []
 *           },
 *           {
 *             "inputName": "email",
 *             "value": "johndoe@mail.com",
 *             "values": []
 *          }
 *         ]
 *       },
 *       "checkedIn": true
 *     }
 * ],
 * "_originQuery": {
 *   "filterTree": {
 *     "$and": []
 *   },
 *  "invalidArguments": [],
 *   "encoder": {},
 *   "transformationPaths": {},
 *   "sort": [],
 *   "paging": {},
 *   "pagingMethod": "CURSOR",
 *   "builderOptions": {
 *     "cursorWithEmptyFilterAndSort": true
 *   }
 * },
 * "_limit": 50,
 * "_nextCursor": "",
 * "_prevCursor": "",
 * "cursors": {
 *   "next": "",
 *   "prev": ""
 * }
 * }
 * } 
 */
```

## Query guests (export from backend code) 

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { guests } from "wix-events.v2";
import { elevate } from 'wix-auth';

/* Sample options value:
 *
 * {
 *    "fields": ["GUEST_DETAILS"]
 * }
 * 
 */
  
export const myQueryGuestsFunction = webMethod(
  Permissions.Anyone, 
  async (options) => {
   try {
     const elevatedQueryGuests = elevate(guests.queryGuests);
     const items = await elevatedQueryGuests(options).find()
     console.log('Success! Guests: ', items)
     return items;
   } catch (error) {
     console.error(error);
     // Handle the error
    }
 });

/* Promise resolves to:
 * {
 * "_items": [
 *  {
 *     "eventId": "3a80a30c-643d-4b11-b38f-1150dbe7c538",
 *     "orderNumber": "2SVV-RH7C-P3D",
 *     "tickets": [],
 *     "contactId": "c64c558f-ed41-4395-b820-f8dd66c31702",
 *     "guestDetails": {
 *      "email": "johndoe@mail.com",
 *       "firstName": "John",
 *       "lastName": "Doe",
 *       "formResponse": {
 *         "inputValues": [
 *          {
 *            "inputName": "firstName",
 *             "value": "John",
 *             "values": []
 *           },
 *           {
 *             "inputName": "lastName",
 *            "value": "Doe",
 *             "values": []
 *           },
 *           {
 *             "inputName": "email",
 *             "value": "johndoe@mail.com",
 *             "values": []
 *          }
 *         ]
 *       },
 *       "checkedIn": true
 *     }
 * ],
 * "_originQuery": {
 *   "filterTree": {
 *     "$and": []
 *   },
 *  "invalidArguments": [],
 *   "encoder": {},
 *   "transformationPaths": {},
 *   "sort": [],
 *   "paging": {},
 *   "pagingMethod": "CURSOR",
 *   "builderOptions": {
 *     "cursorWithEmptyFilterAndSort": true
 *   }
 * },
 * "_limit": 50,
 * "_nextCursor": "",
 * "_prevCursor": "",
 * "cursors": {
 *   "next": "",
 *   "prev": ""
 * }
 * }
 * } 
 */
```

---