Search.../

not( )

Adds a not condition to the query.

Description

The not() function adds a not condition to a PublicPlansQueryBuilder. 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: PublicPlansQueryBuilder): PublicPlansQueryBuilder

not Parameters

NAME
TYPE
DESCRIPTION
query

A query to add to the initial query as a not condition.

Returns

A PublicPlansQueryBuilder object representing 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

The results for this query do not contain any Silver public plans. This is determined by looking for slugs that start with the string "silver."

Copy Code
1import wixPricingPlansBackend from 'wix-pricing-plans-backend';
2
3// ...
4
5wixPricingPlansBackend.queryPublicPlans()
6 .not(wixPricingPlansBackend.queryPublicPlans().startsWith("slug", "silver"))
7 .find()
8 .then((publicPlans) => {
9 if (publicPlans.items.length > 0) {
10 const items = publicPlans.items;
11 const firstItem = items[0];
12 const totalCount = publicPlans.totalCount;
13 const pageSize = publicPlans.pageSize;
14 const currentPage = publicPlans.currentPage;
15 const totalPages = publicPlans.totalPages;
16 const hasNext = publicPlans.hasNext();
17 const hasPrev = publicPlans.hasPrev();
18 const length = publicPlans.length;
19 const query = publicPlans.query;
20 } else {
21 // handle case where no matching items found
22 }
23 })
24 .catch((error) => {
25 const queryError = error;
26 });