Search.../

not( )

Adds an not condition to the query.

Description

The not() function adds a not condition to a ContactsQueryBuilder. A query with a not returns all the items that match the query as defined up to the not function, but don't match the query passed to the not function.

If the query only contains a not() function, it returns all the items that don't match the query defined by the not method.

Syntax

function not(query: ContactsQueryBuilder): ContactsQueryBuilder

not Parameters

NAME
TYPE
DESCRIPTION
query

Contains functionality for refining a contacts query. The ContactsQueryBuilder functions enable you to run, sort, filter, and control which results a query returns.

Typically, you build a query using queryContacts() function, refine the query by chaining ContactsQueryBuilder functions, and then execute the query by chaining the find() function.

Returns

A ContactsQueryBuilder object that contains the refined query.

Was this helpful?

Add a not filter to a query

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

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { contacts } from 'wix-crm-backend';
3
4export const myQueryContactsFunction = webMethod(Permissions.Anyone, () => {
5 return contacts.queryContacts()
6 .not(contacts.queryContacts()
7 .hasSome("info.labelKeys", "custom.stale-lead"))
8 .find()
9 .then((results) => {
10 if (results.items.length > 0) {
11 const items = results.items;
12 const firstItem = items[0];
13 const pageSize = results.pageSize;
14 const hasNext = results.hasNext();
15 const hasPrev = results.hasPrev();
16 const length = results.length;
17 const query = results.query;
18
19 return items;
20 } else {
21 // Handle case where no matching items found
22 }
23 })
24 .catch((error) => {
25 console.error(error);
26 })
27
28});