> 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: find(options: QueryOptions)

# Method package: wixEventsBackend

# Method menu location: wixEventsBackend --> EventsQueryBuilder --> find

# Method Link: https://dev.wix.com/docs/velo/apis/wix-events-backend/wix-events/events-query-builder/find.md

# Method Description:

Returns the items that match the query.

The `find()` function returns a Promise that resolves to the results found
 by the query and some information about the results. The Promise is
 rejected if `find()` is called with incorrect permissions or if any of the
 functions used to refine the query are invalid.

> **Note:** A guest can only view their own events. You can override the permissions by setting the `suppressAuth` option to `true`.



# Method Code Examples:

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

## Perform a find on a query

```javascript
import { wixEvents } from 'wix-events-backend';

// ...

wixEvents.queryEvents()
  .find()
  .then((results) => {
    if (results.items.length > 0) {
      const items = results.items;
      const firstItem = items[0];
      const totalCount = results.totalCount;
      const pageSize = results.pageSize;
      const currentPage = results.currentPage;
      const totalPages = results.totalPages;
      const hasNext = results.hasNext();
      const hasPrev = results.hasPrev();
      const length = results.length;
      const query = results.query;
    } else {
      // handle case where no matching items found
    }
  })
  .catch((error) => {
    const queryError = error;
  });
```

## Retrieve the first 5 upcoming events for a given event manager

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { wixEvents } from 'wix-events-backend';

export const myQueryEventFunction = webMethod(Permissions.Anyone, () => {
  return wixEvents.queryEvents()
    .eq("createdBy", "4c47c608-cfa8-4037-93ac-738f09560ed3")
    .hasSome("status", ["SCHEDULED", "STARTED"])
    .ascending("scheduling.startDate")
    .limit(5)
    .find()
    .then((results) => {
      const firstItem = results.items[0]; //see item below
    })
    .catch((error) => {
      console.error(error);
    });
});

/* firstItem is: 
 *
 * {
 *   "about": "<p>Save the date! Great fair for health-minded people who care about the environment and healthy living. </p>",
 *   "assignedContactsLabel": "custom.crafts-wholistic-craft-fair-time-is-tbd",
 *   "calendarLinks": {
 *     "google": "http://calendar.google.com/calendar/render?action=TEMPLATE&text=Crafts%3A+Wholistic+Craft+Fair&dates=20210930T230000Z%2F20211001T030000Z&location=&details=Thank+you+for+registering+to+our+event%21+Your+tickets+are+attached+to+this+email.+Don%27t+forget+to+bring+them.%0A%0AWe%27re+looking+forward+to+seeing+you+there.%0A%0AHere+are+the+details%3A%0A%0ACrafts%3A+Wholistic+Craft+Fair%0ASeptember+30%2C+2021%2C+7%3A00+PM+%E2%80%93+11%3A00+PM%0AModi%27in-Maccabim-Re%27ut",
 *     "ics": "https://www.wixevents.com/media/calendar/265e0437-7730-43d6-ae24-7918bb9bb05b?token=JWS.eyJraWQiOiJpb21iOUJ0eSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiZXZlbnRJZFwiOntcInZhbHVlXCI6XCIyNjVlMDQzNy03NzMwLTQzZDYtYWUyNC03OTE4YmI5YmIwNWJcIn0sXCJvY0xpbmtcIjpudWxsfSIsImlhdCI6MTYyNjY4OTI2NH0.u9kHEkFXL6dHBOtADjam7KSx0guh4MVUqWRoqKj3ZlY"
 *   },
 *   "createdBy": "4c47c608-cfa8-4037-93ac-738f09560ed3",
 *   "_createdDate": "2021-04-28T06:10:36.714Z",
 *   "description": "This is the annual wholistic craft fair for organic and health-conscious foods, arts, items, crafts, sessions.... and more! ",
 *   "eventUrl": {
 *     "baseUrl": "https://mysite.wixsite.com/lectures",
 *     "path": "/event-details/crafts-wholistic-craft-fair"
 *   },
 *   "form": {
 *     "inputGroups": [
 *       {
 *         "_id": "name",
 *         "inputs": [
 *           {
 *             "additionalLabels": [],
 *             "label": "First Name",
 *             "maxLength": 50,
 *             "name": "firstName",
 *             "options": [],
 *             "required": true,
 *             "type": "TEXT"
 *           },
 *           {
 *             "additionalLabels": [],
 *             "label": "Last Name",
 *             "maxLength": 50,
 *             "name": "lastName",
 *             "options": [],
 *             "required": true,
 *             "type": "TEXT"
 *           }
 *         ],
 *         "orderIndex": 0,
 *         "system": true,
 *         "type": "NAME"
 *       },
 *       {
 *         "_id": "email",
 *         "inputs": [
 *           {
 *             "additionalLabels": [],
 *             "label": "Email",
 *             "maxLength": 50,
 *             "name": "email",
 *             "options": [],
 *             "required": true,
 *             "type": "TEXT"
 *           }
 *         ],
 *         "orderIndex": 1,
 *         "system": true,
 *         "type": "INPUT"
 *       }
 *     ],
 *     "messages": {
 *       "checkout": {
 *         "checkoutLabel": "Continue",
 *         "title": "Add Your Details"
 *       },
 *       "registrationClosed": {
 *         "exploreEventsLabel": "See other events",
 *         "message": "Registration is Closed"
 *       },
 *       "rsvp": {
 *         "noMessages": {
 *           "confirmationTitle": "Sorry You Can't Make It",
 *           "shareLabel": "Share",
 *           "title": "Add Your Details"
 *         },
 *         "rsvpNo": "Not Going",
 *         "rsvpYes": "I'm Going",
 *         "submitRsvpLabel": "SUBMIT",
 *         "waitingMessages": {
 *           "addToCalendarLabel": "Add to Calendar",
 *           "confirmationMessage": "We'll update you if additional spots become available.",
 *           "confirmationTitle": "Thanks! You've been added to the waitlist.",
 *           "shareLabel": "Share",
 *           "title": "Looks Like This Event Is Full. Join the waiting list"
 *         },
 *         "yesMessages": {
 *           "addToCalendarLabel": "Add to Calendar",
 *           "confirmationMessage": "An email with all the event info was sent to you.",
 *           "confirmationTitle": "Thank you! See you soon.",
 *           "shareLabel": "Share",
 *           "title": "Add Your Details"
 *         }
 *       }
 *     }
 *   },
 *   "guestList": {
 *     "public": true
 *   },
 *   "_id": "265e0437-7730-43d6-ae24-7918bb9bb05b",
 *   "language": "en",
 *   "location": {
 *     "name": "My Location",
 *     "tbd": true,
 *     "type": "VENUE"
 *   },
 *   "mainImage": "wix:image://v1/c1ec532b6db54aa4bc3275363c5ba35e.jpg/file#originWidth=2700&originHeight=1800",
 *   "registration": {
 *     "initialType": "TICKETS",
 *     "restrictedTo": "VISITOR",
 *     "rsvp": {
 *       "responseOptions": "YES_ONLY",
 *       "waitlist": false
 *     },
 *     "status": "OPEN_TICKETS",
 *     "tickets": {
 *       "currency": "USD",
 *       "formAssignedPerTicket": false,
 *       "highestTicketPrice": {
 *         "currency": "USD",
 *         "value": "20.50"
 *       },
 *       "highestTicketPriceFormatted": "$20.50",
 *       "lowestTicketPrice": {
 *         "currency": "USD",
 *         "value": "10.25"
 *       },
 *       "lowestTicketPriceFormatted": "$10.25",
 *       "tax": {}
 *     },
 *     "type": "TICKETS"
 *   },
 *   "scheduling": {
 *     "endDate": "2021-10-01T03:00:00.000Z",
 *     "formatted": "September 30, 2021, 7:00 PM – 11:00 PM",
 *     "hideEndDate": false,
 *     "showTimeZone": false,
 *     "startDate": "2021-09-30T23:00:00.000Z",
 *     "startDateFormatted": "September 30, 2021",
 *     "startTimeFormatted": "7:00 PM",
 *     "tbd": false,
 *     "timeZoneId": "America/New_York"
 *   },
 *   "slug": "crafts-wholistic-craft-fair",
 *   "status": "SCHEDULED",
 *   "summary": {
 *     "rsvp": {},
 *     "tickets": {
 *       "revenue": {},
 *       "totalSales": {}
 *     }
 *   },
 *   "title": "Crafts: Wholistic Craft Fair",
 *   "_updatedDate": "2021-07-12T14:18:07.000Z",
 *   "videoConferencing": {
 *     "session": {}
 *   }
 * }
 */
```

---