I have an inventory (not a Wix store) page which consists of a repeater, connected to a database collection via a dataset. Simple, and basic. The displayed items in the repeater are based on two variables:
a search term:
"searchWord" from {local} on load or $w('#searchBar").value on 'Enter' or button click
the boolean value:
of "active" in the database collection (connected via "NEWinventoryDataset")
Everything seems to be working fine with the exception of the "active" value. I need to filter the repeater items according to search parameters but ONLY show units with "active" checked as true. Yet on my live site I consistently see units appear in the repeater that are NOT active in the database.
Here is the relevant code:
import {local} from 'wix-storage';
import wixData from 'wix-data';
$w.onReady(function() { var sameWord = local.getItem("searchWord"); //searchWord set from Home page nav $w("#searchBar").value = sameWord; $w("#searchBar").placeholder = sameWord; $w('#titleCurrentSearch').text = "Inventory Search > New RVs > " + sameWord; $w('#NEWinventoryDataset').onReady(function () { search(); }); });
// I believe the problem is in this part: I require to filter to allow show ACTIVE units that match the search term with ANY of the listed parameters. function search() { $w("#NEWinventoryDataset").setFilter(wixData.filter().eq("active", true) .and(wixData.filter().contains("description", $w("#searchBar").value)) .or(wixData.filter().contains("category", $w("#searchBar").value)) .or(wixData.filter().contains("brand", $w("#searchBar").value)) .or(wixData.filter().contains("model",$w("#searchBar").value)) .or(wixData.filter().contains("title",$w("#searchBar").value)) .or(wixData.filter().contains("year",$w("#searchBar").value)) .or(wixData.filter().contains("keywords",$w("#searchBar").value)) .or(wixData.filter().contains("comparableModels",$w("#searchBar").value)) ) .then( () => { console.log("Dataset is now filtered"); $w("#NEWinventoryDataset").setSort(wixData.sort() .ascending("ourPrice") ); } ) .catch( (err) => { console.log(err); } ); }
I have additional items on this page like a search bar, search by category list, search by brand list, and a clear filters buttons. I omitted them from the above code for clarity. All are working fine, with the exception of the "active" part.
My client changes the available units by using the Wix Dashboard access to the databases, they need to be able to turn off and on the "active" value for the units, and have it reflected on the live page.
The page in question is currently sitting at a testing URL => https://www.401test.com/new-rvs if that helps clarify anything at all.
I am fairly new to code, only a few months in... What am I missing?