The WixDataFilter functions enable you to filter and control which results are returned by a dataset when the setFilter() function is applied.

A filter is used to control which data is contained in a dataset on your page.

Typically, you build a filter using the filter() function, refine the filter with WixDataFilter functions, and then apply the filter to the dataset using the setFilter() function.

For example, the following code shows a filter on a dataset that is connected to a collection containing customer data. The filter includes only customers over the age of 20:

import wixData from 'wix-data';
const customerFilter = wixData.filter()
.gt("age", 20);
javascript | Copy Code

When working with Wix app collections, check which fields can be used in a filter.

The functions below are common to both queries and filters. The examples given are for queries but also work for filters.

Was this helpful?