Search.../

endsWith( )

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

Description

The endsWith() function refines a PublicPlansQueryBuilder to only match items where the value of the specified property ends with the specified string. Matching with endsWith() is case-sensitive, so "TEXT" does not end with "ext".

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

Syntax

function endsWith(propertyName: string, string: string): PublicPlansQueryBuilder

endsWith Parameters

NAME
TYPE
DESCRIPTION
propertyName
string

The property whose value will be compared with the string.

Supported property: slug

string
string

The string to look for at the end of the specified property value.

Returns

A PublicPlansQueryBuilder object representing the refined query.

Was this helpful?

Add an "ends with" filter to a query

Copy Code
1const newQuery = wixPricingPlansBackend.queryPublicPlans().endsWith("slug", "vip");
Create a query, add an "ends with" filter, and run it

Copy Code
1import wixPricingPlansBackend from 'wix-pricing-plans-backend';
2
3// ...
4
5wixPricingPlansBackend.queryPublicPlans()
6 .endsWith("slug", "vip")
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 });