Hi,
I’m trying to query my dataset to get the unique list of values from a column called ‘makeclean’. The below formula worked but my dataset is now bigger than 1,000 - it’s up to about 10,000 so the below no longer works.
const setMakeDropdown = () => {
wixData.query("Scraper")
.limit(1000)
.find()
.then(res => {
// Filter duplicates and reorder
let makes = res.items.map(({ makeclean }) => makeclean);
makes = [...new Set(makes)].sort();
// Create makes options list
let options = [{ 'value': "", 'label': "Any Make" }];
options.push(...makes.map(makeclean => {
return { "value": makeclean, "label": makeclean };
}));
$w('#makeDropdown').options = options;
})
};
Instead using the below code to search through all 10,000 results. How can I link the below code into the above code to search all 10,000 results and then display them in a dropdown list (sorted and with duplicates removed [this is what the code above does])
async function fetchData() {
let result = await wixData.query("Scraper")
.limit(1000)
.find(); // Result is WixDataQueryResult and has next() method
let allItems = result.items;
while (result.hasNext()) { // Repeat while there is a next page
result = await result.next(); // We fetch next page the easy way, without using skip and limit
allItems = allItems.concat(result.items); // We add results of the next page to allItems
}
return allItems; // In the end we return the list of items from all pages
}
Thank you so much,
Giles