Filter Dataset Based on Two Fields in a Collection

Hi folks!

So tag1 and tag2 are fields in a collection. In the code below, I’m trying to make it so that " #dataset1 "(that is connected to the collection) is filtered by the " #filterInput " value by searching the contents of the fields tag1 AND tag2 and then filtering if there is a match in either tag1 OR tag2. The code works with either tag1 or tag2 at this point. I’ve tried the || operator but it doesn’t work.

export function filterInput_change(event) { $w(" #dataset1 “).setFilter(wixData.filter() .contains(“tag1” || “tag2”, $w(” #filterInput ").value)); }

Let’s say filterInput = “Apples” … I’m trying to get it so that then dataset1 will be filtered to show only those entries that have the word “apples” in either tag1 OR tag2.

Any help would be much appreciated.

thanks!

Greg

HI, please review wix-dataset - Velo API Reference - Wix.com $w(“#myDataset”).setFilter( wixData.filter() . contains(“tag1”, “apple”) .or( wixData.filter() .contains(“tag2”, “apple”) ) ) .then( () => { console.log(“Dataset is now filtered”); } ) .catch( (err) => { console.log(err); } );