Search...
not( )
Adds a not
condition to the query or filter.
Description
The not()
function adds a not
condition to a WixDataQuery
or WixDataFilter
. A query or filter with a not
returns all the items that match the query or filter as defined up to the not
function, but don't match the query or filter passed to the not
function.
If the query or filter only contains a not()
function, it returns all the items
that don't match the query defined by the not
method.
The collections referenced by both the initial query and the query passed
to the not
function must be the same.
Syntax
function not(query: WixDataQuery): WixDataQuery
not Parameters
NAME
TYPE
DESCRIPTION
Was this helpful?
Add a not to a query
Copy Code
1let newQuery = query1.not(query2);
Create a query, add a not, and run it
Copy Code
1import wixData from 'wix-data';23// ...45wixData.query("myCollection")6 .gt("age", 25)7 .not(8 wixData.query("myCollection")9 .eq("access_type", "restricted")10 )11 .find()12 .then((results) => {13 if(results.items.length > 0) {14 let items = results.items;15 let firstItem = items[0];16 let totalCount = results.totalCount;17 let pageSize = results.pageSize;18 let currentPage = results.currentPage;19 let totalPages = results.totalPages;20 let hasNext = results.hasNext();21 let hasPrev = results.hasPrev();22 let length = results.length;23 let query = results.query;24 } else {25 // handle case where no matching items found26 }27 })28 .catch((error) => {29 let errorMsg = error.message;30 let code = error.code;31 });