Search.../

contains( )

Refines a query to match items whose specified property value contains a specified string.

Description

The contains() function refines an EventsQueryBuilder to only match items where the value of the specified property contains the specified string. Matching with contains() is case-sensitive, so "TEXT" does not contain "text".

You can only use contains() with a property whose value is a String.

Syntax

function contains(propertyName: string, value: string): EventsQueryBuilder

contains Parameters

NAME
TYPE
DESCRIPTION
propertyName
string

The property whose value will be compared with value.

Supported properties:

  • title
  • status
  • slug
value
string

The value to match against.

Returns

Contains functionality for refining a Wix events query.

Return Type:

Was this helpful?

Add a 'contains' filter to a query

Copy Code
1const newQuery = wixEvents.queryEvents().contains("slug", "free");
Create a query, add a 'contains' filter, and run it

Copy Code
1import { wixEvents } from 'wix-events-backend';
2
3// ...
4
5wixEvents.queryEvents()
6 .contains("slug", "free")
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 found
22 }
23 })
24 .catch((error) => {
25 const queryError = error;
26 });