I am trying to filter a dataset of charities based on the parameters selected. Right now I have it so that if I want charities that help “Animals” and are “Local”, I can display ones that help animals OR are local. Along with these results are ones that help animals AND are local — but they’re not necessarily the first ones that come up. I still want to display charities that don’t match every parameter (that’s why I’m not using .hasAll), but I want the best results to show up as the first rows in the dataset.
function filter(categories) {
let newCategoriesFilterCheck = compareArrays(categories, lastFilterCategories);
if (!newCategoriesFilterCheck) {
let newFilter = wixData.filter();
// categories is an array with all of the selected parameters
if(categories.length!=0){
newFilter = newFilter.hasAll('allTags', categories);
console.log(newFilter);
}
$w('#dataset1').setFilter(newFilter).then(function () {
let count = $w("#dataset1").getTotalCount();
});
lastFilterCategories = categories;
}
}
Thank you!