Search...
in( )
Refines a query to only match items where the specified property conatins any of the values in the provided array of values.
Description
The in()
function refines a DraftPostsQueryBuilder
to match only items where the specified propertyName
is equal to any of the values in the provided array.
Matching strings with in()
is case-sensitive, so 'text'
isn't equal to 'Text'
.
Syntax
function in(propertyName: string, value: any): DraftPostsQueryBuilder
in Parameters
NAME
TYPE
DESCRIPTION
propertyName
Optional
string
value
Optional
any
Returns
Return Type:
Was this helpful?
Add an
in
filter to a queryCopy Code
1const query = draftPosts.queryDraftPosts.in(2 ['labelIds', 'colors'],3 ['red', 'blue', 'purple']4);5
Create a query, add an
in
filter, and run itCopy Code
1import { draftPosts } from 'wix-blog-backend';23export async function myQueryFunction() {4 const results = await draftPosts5 .queryDraftPosts()6 .in(['labelIds', 'colors'], ['red', 'blue', 'purple'])7 .find();89 if (results.items.length > 0) {10 const items = results.items;11 const firstItem = items[0];12 const pageSize = results.pageSize;13 const hasNext = results.hasNext();14 const hasPrev = results.hasPrev();15 const length = results.length;16 const query = results.query;1718 return items;19 } else {20 // Handle if no matching items found21 }22}23