Adds an or
condition to the query.
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.
function or(query: ContactsQueryBuilder): ContactsQueryBuilder;
A query to add to the initial query as an or
condition.
import { Permissions, webMethod } from "wix-web-module";
import { contacts } from "wix-crm-backend";
export const myQueryContactsFunction = webMethod(Permissions.Anyone, () => {
return contacts
.queryContacts()
.eq("info.addresses.country", "GB")
.or(contacts.queryContacts().eq("info.addresses.country", "FR"))
.find()
.then((results) => {
if (results.items.length > 0) {
const items = results.items;
const firstItem = items[0];
const pageSize = results.pageSize;
const hasNext = results.hasNext();
const hasPrev = results.hasPrev();
const length = results.length;
const query = results.query;
return items;
} else {
// Handle case where no matching items found
}
})
.catch((error) => {
console.error(error);
});
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.