Search...
hasSome( )
Developer Preview
Refines a query to match items whose specified property contains any of the specified values.
Description
The hasSome()
function refines a ProductsQueryBuilder
to match only items where the value of the specified propertyName
equals any of the specified values
.
Matching strings with hasSome()
is case-sensitive, so 'text'
isn't equal to 'Text'
.
If the specified property is an array, hasSome()
matches if any of that array's elements equal any of the specified values.
Syntax
function hasSome(propertyName: string, value: Array<any>): ProductsQueryBuilder
hasSome Parameters
NAME
TYPE
DESCRIPTION
propertyName
Optional
string
Property whose value is compared with values
.
value
Optional
Array<
any
>Returns
Return Type:
Was this helpful?
Add a
hasSome
filter to a queryCopy Code
1const query = products.queryProducts.hasSome('labelIds', [2 'red',3 'blue',4 'purple',5]);6
Create a query, add a
hasSome
filter, and run itCopy Code
1import { products } from 'wix-stores.v2';23export async function myQueryFunction() {4 const results = await products5 .queryProducts()6 .hasSome('labelIds', ['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