Search...
or( )
Adds an or
condition to the query.
Description
The or()
function adds an inclusive or
condition to a ContactsQueryBuilder
. 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: ContactsQueryBuilder): ContactsQueryBuilder
or Parameters
NAME
TYPE
DESCRIPTION
Returns
A ContactsQueryBuilder
object that contains the refined query.
Return Type:
Was this helpful?
Add an
or
filter to a queryCopy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const myQueryContactsFunction = webMethod(Permissions.Anyone, () => {5 return contacts.queryContacts()6 .eq("info.addresses.country", "GB")7 .or(contacts.queryContacts()8 .eq("info.addresses.country", "FR"))9 .find()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 hasNext = results.hasNext();16 const hasPrev = results.hasPrev();17 const length = results.length;18 const query = results.query;1920 return items;21 } else {22 // Handle case where no matching items found23 }24 })25 .catch((error) => {26 console.error(error);27 })2829});
Create a query, add an
or
filter, and run itCopy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const myQueryContactsFunction = webMethod(Permissions.Anyone, () => {5 return contacts.queryContacts()6 .eq("info.addresses.country", "GB")7 .or(contacts.queryContacts()8 .eq("info.addresses.country", "FR"))9 .find()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 hasNext = results.hasNext();16 const hasPrev = results.hasPrev();17 const length = results.length;18 const query = results.query;1920 return items;21 } else {22 // Handle case where no matching items found23 }24 })25 .catch((error) => {26 console.error(error);27 })2829});