Search.../

exists( )

Developer Preview

Refines a query to match items where the specified property contains a value.

Description

The exists() function refines a GroupRequestsQueryBuilder to only match items where the value of the specified propertyName doesn't equal null or undefined. exists() checks for either existence or non-existence based on the boolen parameter. Note that exists() does match items where the value of the specified propertyName is an empty string or an invalid value. exists() is only useful for properties which don't contain default values and therefore their values may be unassigned.

Syntax

function exists(propertyName: string, value: boolean): GroupRequestsQueryBuilder

exists Parameters

NAME
TYPE
DESCRIPTION
propertyName
Optional
string
value
Optional
boolean

Returns

Was this helpful?

Add an exists filter to a query

Copy Code
1const query = createRequests.queryGroupRequests.exists(
2 'description',
3 'some-description'
4);
5
Create a query, add an exists filter, and run it

Copy Code
1import { createRequests } from 'wix-groups.v2';
2
3export async function myQueryFunction() {
4 const results = await createRequests
5 .queryGroupRequests()
6 .exists('description', 'some-description')
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