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 ServicesQueryBuilder 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>): ServicesQueryBuilder

hasSome Parameters

NAME
TYPE
DESCRIPTION
propertyName
Optional
string

Property whose value is compared with values.

value
Optional
Array<
any
>

Returns

Was this helpful?

Add a hasSome filter to a query

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

Copy Code
1import { services } from 'wix-bookings.v2';
2
3export async function myQueryFunction() {
4 const results = await services
5 .queryServices()
6 .hasSome('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