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 ServicesQueryBuilder
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): ServicesQueryBuilder
startsWith Parameters
NAME
TYPE
DESCRIPTION
propertyName
Optional
string
Property whose value is compared with string
.
value
Optional
string
Returns
Return Type:
Was this helpful?
Add a
startsWith
filter to a queryCopy Code
1const query = services.queryServices.startsWith('_id', 'L');2
Create a query, add a
startsWith
filter, and run itCopy Code
1import { services } from 'wix-bookings.v2';23export async function myQueryFunction() {4 const results = await services.queryServices();5 startsWith('_id', 'L').find();67 if (results.items.length > 0) {8 const items = results.items;9 const firstItem = items[0];10 const pageSize = results.pageSize;11 const hasNext = results.hasNext();12 const hasPrev = results.hasPrev();13 const length = results.length;14 const query = results.query;1516 return items;17 } else {18 // Handle if no matching items found19 }20}21