and( )


Adds an and condition to the query.

The and() function adds an and condition to an EventsQueryBuilder. A query with an and returns all the items that match the query as defined up to the and function and also match the query or filter passed to the and function.

Note that when chaining multiple EventsQueryBuilder functions to a query an and condition is assumed. In such cases, you do not need to add a call to the and() function. For example, this query returns results where status is either SCHEDULED or STARTED and a specific event manager created the event.

Copy
wixEvents .queryEvents() .hasSome("status", ["SCHEDULED", "STARTED"]) .eq("createdBy", "4c47c608-cfa8-4037-93ac-738f09560ed3");

The and() function is needed when performing compound queries. For example, the final query in this set of queries returns results where the event is an introductory class whose title contains either beginner or basic and whose status is either STARTED or ENDED. If both these conditions are true we might want to let the participants for these introductory classes know about upcoming intermediate level classes.

Copy
let levelQuery = wixEvents .queryEvents() .contains("title", "beginner") .or(wixEvents.queryEvents().contains("title", "basic")); let statusQuery = wixEvents .queryEvents() .hasSome("status", ["STARTED", "ENDED"]); let readyForIntermediateQuery = levelQuery.and(statusQuery);

The and() function is designed to work with 2 or more queries or filters. If you use it on its own, it will return all the items in a collection.

Method Declaration
Copy
function and(query: EventsQueryBuilder): EventsQueryBuilder;
Method Parameters
queryEventsQueryBuilderRequired

Contains functionality for refining a Wix events query.

Returns
Return Type:EventsQueryBuilder
JavaScript
const newQuery = query1.and(query2);
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?