Search...
startsWith( )
Refines a query to match items where the specified property starts with the specified value.
Description
The startsWith()
function refines a DraftPostsQueryBuilder
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): DraftPostsQueryBuilder
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 = draftPosts.queryDraftPosts.startsWith('title', 'L');2
Create a query, add a
startsWith
filter, and run itCopy Code
1import { draftPosts } from 'wix-blog-backend';23export async function myQueryFunction() {4 const results = await draftPosts.queryDraftPosts();5 startsWith('title', '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