Hi,
I think all my other problems might be related to this one. I didn’t realise I wasn’t getting all the results in my query.
I need the uniqueTitles as labels in a dropdown list. so i can filter a referenced collection otherwise my repeater is huge and slows to a halt during testing if i add more than 50 repeating items.
CODE EXAMPLE HERE…
$w.onReady(function () {
//Populate Common Name dropdown
wixData.query(“Collection_Ref”)
.ascending(“CommonName”)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdownCommonName”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
// Use the map method to create the titlesOnly object containing all the titles from the query res
const titlesOnly = items.map(item => item.CommonName);
// Return an array with a list of unique titles
return […new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
// Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle}
return { label: curr, value: curr };
});
}
});