find( )
Returns the items that match the query.
Description
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 totrue
.
Syntax
function find([options: QueryOptions]): Promise<EventsQueryResult>
find Parameters
NAME
TYPE
DESCRIPTION
Options to use when performing a query or query count.
Returns
Fulfilled - The results of a Wix events query, containing the retrieved items.
When you execute a query with the find()
function, it returns a Promise that resolves to an EventsQueryResult
object.
This object contains the items that match the query, information about the
query itself, and functions for paging through the query results.
Rejected - Error that caused the query to fail.
Return Type:
Was this helpful?
1import { wixEvents } from 'wix-events-backend';23// ...45wixEvents.queryEvents()6 .find()7 .then((results) => {8 if (results.items.length > 0) {9 const items = results.items;10 const firstItem = items[0];11 const totalCount = results.totalCount;12 const pageSize = results.pageSize;13 const currentPage = results.currentPage;14 const totalPages = results.totalPages;15 const hasNext = results.hasNext();16 const hasPrev = results.hasPrev();17 const length = results.length;18 const query = results.query;19 } else {20 // handle case where no matching items found21 }22 })23 .catch((error) => {24 const queryError = error;25 });
1import { Permissions, webMethod } from 'wix-web-module';2import { wixEvents } from 'wix-events-backend';34export const myQueryEventFunction = webMethod(Permissions.Anyone, () => {5 return wixEvents.queryEvents()6 .eq("createdBy", "4c47c608-cfa8-4037-93ac-738f09560ed3")7 .hasSome("status", ["SCHEDULED", "STARTED"])8 .ascending("scheduling.startDate")9 .limit(5)10 .find()11 .then((results) => {12 const firstItem = results.items[0]; //see item below13 })14 .catch((error) => {15 console.error(error);16 });17});1819/* firstItem is:20 *21 * {22 * "about": "<p>Save the date! Great fair for health-minded people who care about the environment and healthy living. </p>",23 * "assignedContactsLabel": "custom.crafts-wholistic-craft-fair-time-is-tbd",24 * "calendarLinks": {25 * "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",26 * "ics": "https://www.wixevents.com/media/calendar/265e0437-7730-43d6-ae24-7918bb9bb05b?token=JWS.eyJraWQiOiJpb21iOUJ0eSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiZXZlbnRJZFwiOntcInZhbHVlXCI6XCIyNjVlMDQzNy03NzMwLTQzZDYtYWUyNC03OTE4YmI5YmIwNWJcIn0sXCJvY0xpbmtcIjpudWxsfSIsImlhdCI6MTYyNjY4OTI2NH0.u9kHEkFXL6dHBOtADjam7KSx0guh4MVUqWRoqKj3ZlY"27 * },28 * "createdBy": "4c47c608-cfa8-4037-93ac-738f09560ed3",29 * "_createdDate": "2021-04-28T06:10:36.714Z",30 * "description": "This is the annual wholistic craft fair for organic and health-conscious foods, arts, items, crafts, sessions.... and more! ",31 * "eventUrl": {32 * "baseUrl": "https://mysite.wixsite.com/lectures",33 * "path": "/event-details/crafts-wholistic-craft-fair"34 * },35 * "form": {36 * "inputGroups": [37 * {38 * "_id": "name",39 * "inputs": [40 * {41 * "additionalLabels": [],42 * "label": "First Name",43 * "maxLength": 50,44 * "name": "firstName",45 * "options": [],46 * "required": true,47 * "type": "TEXT"48 * },49 * {50 * "additionalLabels": [],51 * "label": "Last Name",52 * "maxLength": 50,53 * "name": "lastName",54 * "options": [],55 * "required": true,56 * "type": "TEXT"57 * }58 * ],59 * "orderIndex": 0,60 * "system": true,61 * "type": "NAME"62 * },63 * {64 * "_id": "email",65 * "inputs": [66 * {67 * "additionalLabels": [],68 * "label": "Email",69 * "maxLength": 50,70 * "name": "email",71 * "options": [],72 * "required": true,73 * "type": "TEXT"74 * }75 * ],76 * "orderIndex": 1,77 * "system": true,78 * "type": "INPUT"79 * }80 * ],81 * "messages": {82 * "checkout": {83 * "checkoutLabel": "Continue",84 * "title": "Add Your Details"85 * },86 * "registrationClosed": {87 * "exploreEventsLabel": "See other events",88 * "message": "Registration is Closed"89 * },90 * "rsvp": {91 * "noMessages": {92 * "confirmationTitle": "Sorry You Can't Make It",93 * "shareLabel": "Share",94 * "title": "Add Your Details"95 * },96 * "rsvpNo": "Not Going",97 * "rsvpYes": "I'm Going",98 * "submitRsvpLabel": "SUBMIT",99 * "waitingMessages": {100 * "addToCalendarLabel": "Add to Calendar",101 * "confirmationMessage": "We'll update you if additional spots become available.",102 * "confirmationTitle": "Thanks! You've been added to the waitlist.",103 * "shareLabel": "Share",104 * "title": "Looks Like This Event Is Full. Join the waiting list"105 * },106 * "yesMessages": {107 * "addToCalendarLabel": "Add to Calendar",108 * "confirmationMessage": "An email with all the event info was sent to you.",109 * "confirmationTitle": "Thank you! See you soon.",110 * "shareLabel": "Share",111 * "title": "Add Your Details"112 * }113 * }114 * }115 * },116 * "guestList": {117 * "public": true118 * },119 * "_id": "265e0437-7730-43d6-ae24-7918bb9bb05b",120 * "language": "en",121 * "location": {122 * "name": "My Location",123 * "tbd": true,124 * "type": "VENUE"125 * },126 * "mainImage": "wix:image://v1/c1ec532b6db54aa4bc3275363c5ba35e.jpg/file#originWidth=2700&originHeight=1800",127 * "registration": {128 * "initialType": "TICKETS",129 * "restrictedTo": "VISITOR",130 * "rsvp": {131 * "responseOptions": "YES_ONLY",132 * "waitlist": false133 * },134 * "status": "OPEN_TICKETS",135 * "tickets": {136 * "currency": "USD",137 * "formAssignedPerTicket": false,138 * "highestTicketPrice": {139 * "currency": "USD",140 * "value": "20.50"141 * },142 * "highestTicketPriceFormatted": "$20.50",143 * "lowestTicketPrice": {144 * "currency": "USD",145 * "value": "10.25"146 * },147 * "lowestTicketPriceFormatted": "$10.25",148 * "tax": {}149 * },150 * "type": "TICKETS"151 * },152 * "scheduling": {153 * "endDate": "2021-10-01T03:00:00.000Z",154 * "formatted": "September 30, 2021, 7:00 PM – 11:00 PM",155 * "hideEndDate": false,156 * "showTimeZone": false,157 * "startDate": "2021-09-30T23:00:00.000Z",158 * "startDateFormatted": "September 30, 2021",159 * "startTimeFormatted": "7:00 PM",160 * "tbd": false,161 * "timeZoneId": "America/New_York"162 * },163 * "slug": "crafts-wholistic-craft-fair",164 * "status": "SCHEDULED",165 * "summary": {166 * "rsvp": {},167 * "tickets": {168 * "revenue": {},169 * "totalSales": {}170 * }171 * },172 * "title": "Crafts: Wholistic Craft Fair",173 * "_updatedDate": "2021-07-12T14:18:07.000Z",174 * "videoConferencing": {175 * "session": {}176 * }177 * }178 */