Search.../

hasAll( )

Developer Preview

Refines a query to match items whose specified property contains all of the specified values.

Description

The hasAll() function refines a ProductsQueryBuilder to match only items where the value of the specified propertyName equals all of the specified values. Matching strings with hasAll() is case-sensitive, so 'text' isn't equal to 'Text'. If the specified property is an array, hasAll() matches if that array's elements match all of the specified values.

Syntax

function hasAll(propertyName: string, value: Array<any>): ProductsQueryBuilder

hasAll Parameters

NAME
TYPE
DESCRIPTION
propertyName
Optional
string

Property whose value is compared with values.

value
Optional
Array<
any
>

Returns

Was this helpful?

Add a hasAll filter to a query

Copy Code
1const query = products.queryProducts.hasAll('labelIds', [
2 'red',
3 'blue',
4 'purple',
5]);
6
Create a query, add a hasAll filter, and run it

Copy Code
1import { products } from 'wix-stores.v2';
2
3export async function myQueryFunction() {
4 const results = await products
5 .queryProducts()
6 .hasAll('labelIds', ['red', 'blue', 'purple'])
7 .find();
8
9 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;
17
18 return items;
19 } else {
20 // Handle if no matching items found
21 }
22}
23