Search.../

startsWith( )

Developer Preview

Refines a query to match items where the specified property starts with the specified value.

Description

The startsWith() function refines a RequestsQueryBuilder to match only items where the value of the specified propertyName starts with the specified string. Matching with startsWith() is case-sensitive, so 'TEXT' doesn't start with 'text'. You can only use startsWith() with a property whose value is a string.

Syntax

function startsWith(propertyName: string, value: string): RequestsQueryBuilder

startsWith Parameters

NAME
TYPE
DESCRIPTION
propertyName
Optional
string

Property whose value is compared with string.

value
Optional
string

Returns

Was this helpful?

Add a startsWith filter to a query

Copy Code
1const query =
2 backInStockNotifications.queryBackInStockNotificationRequests.startsWith(
3 '_id',
4 'L'
5 );
6
Create a query, add a startsWith filter, and run it

Copy Code
1import { backInStockNotifications } from 'wix-ecom-backend';
2
3export async function myQueryFunction() {
4 const results =
5 await backInStockNotifications.queryBackInStockNotificationRequests();
6 startsWith('_id', 'L').find();
7
8 if (results.items.length > 0) {
9 const items = results.items;
10 const firstItem = items[0];
11 const pageSize = results.pageSize;
12 const hasNext = results.hasNext();
13 const hasPrev = results.hasPrev();
14 const length = results.length;
15 const query = results.query;
16
17 return items;
18 } else {
19 // Handle if no matching items found
20 }
21}
22