Search...
eq( )
Refines a query to match items whose specified property value equals the specified value.
Description
The eq()
function refines an EventsQueryBuilder
to only
match items where the value of the specified property equals the specified value
.
It only matches values of the same type. For example, a number value stored as a String type does not match the same number stored as a Number type.
Matching strings with eq()
is case sensitive, so "text"
is not equal to "Text"
.
If the value of the propertyName
property is an Array, eq()
includes items
in which any of the elements of the Array match the specified value
.
Syntax
function eq(propertyName: string, value: *): EventsQueryBuilder
eq Parameters
NAME
TYPE
DESCRIPTION
propertyName
string
The property whose value will be compared with value
.
Supported properties:
_id
title
createdBy
status
slug
value
*
The value to match against.
Was this helpful?
Add an "equals" filter to a query
Copy Code
1const query = wixEvents.queryEvents().eq("primary", true);
Create a query, add an "equals" filter, and run it
Copy Code
1import { wixEvents } from 'wix-events-backend';23// ...45wixEvents.queryEvents()6 .eq("primary", false)7 .find()8 .then((results) => {9 if (results.items.length > 0) {10 const items = results.items;11 const firstItem = items[0];12 const totalCount = results.totalCount;13 const pageSize = results.pageSize;14 const currentPage = results.currentPage;15 const totalPages = results.totalPages;16 const hasNext = results.hasNext();17 const hasPrev = results.hasPrev();18 const length = results.length;19 const query = results.query;20 } else {21 // handle case where no matching items found22 }23 })24 .catch((error) => {25 const queryError = error;26 });
Retrieve the first 5 upcoming events for a given event manager
Copy Code
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 */