Search.../

or( )

Adds an or condition to the query.

Description

The or() function adds an inclusive or condition to a JoinRequestsQueryBuilder. A query with an or returns all the items that match the query as defined up to the or function, the items that match the query passed to the or function, and the items that match both.

The or() function is designed to work with 2 or more queries. If you use it on its own, it will return all the items that meet the query criteria.

Syntax

function or(query: JoinRequestsQueryBuilder): JoinRequestsQueryBuilder

or Parameters

NAME
TYPE
DESCRIPTION
query

A query to add to the initial query as an or condition.

Returns

A JoinRequestsQueryBuilder object representing the refined query.

Was this helpful?

Add an or filter to a query

Copy Code
1const query = query1.or(query2);
Create a query, add an or filter, and run it

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { joinRequests } from 'wix-groups-backend';
3
4export const myQueryJoinRequestsFunction = webMethod(Permissions.Anyone, () => {
5 return joinRequests.queryJoinRequests()
6 .eq("status", "REJECTED")
7 .or(joinRequests.queryJoinRequests()
8 .eq("status", "APPROVED"))
9 .find({suppressAuth: true})
10 .then((results) => {
11 if (results.items.length > 0) {
12 const items = results.items;
13 const firstItem = items[0];
14 const pageSize = results.pageSize;
15 const totalPages = results.totalPages;
16 const totalCount = results.totalCount;
17 const currentPage = results.currentPage();
18 const next = results.next();
19 const previous = results.prev();
20 const hasNext = results.hasNext();
21 const hasPrev = results.hasPrev();
22 const length = results.length;
23
24 return items;
25 } else {
26 // Handle case where no matching items found
27 }
28 })
29 .catch((error) => {
30 console.error(error);
31 })
32
33});