Hello guys. Trying to query database with more than 1000 entries to push data into a repeater.
Seeing other posts in the forum, (thanks for this), I’ve managed to build the data query, but it is not pushing into the repeater.
Can anyone please advise what I am doing wrong?
TIA!
Code below:
import wixData from 'wix-data';
$w.onReady(function () {
$w("#dynamicDataset").onReady( () => {
$w('#OUcountryname').text = $w("#dynamicDataset").getCurrentItem().countryName;
console.log($w("#dynamicDataset").getCurrentItem().countryName);
$w('#OUregion').text = $w("#dynamicDataset").getCurrentItem().region;
$w("#repeater1").onItemReady( ($item, itemData, index) => {
console.log(index);
if(index < 9){
$item("#OuOpsUpdatetext").text = "Ops update:00" + String(index+1);
}
else if (index >= 9){
$item("#OuOpsUpdatetext").text = "Ops update:0" + String(index+1);
}
else if (index > 100){
$item("#OuOpsUpdatetext").text = "Ops update:" + String(index+1);
}
$item("#textfromOUDB").text = itemData.opsUpdate;
});
wixData.query("OpsUpdate")
.eq("countryName", $w("#dynamicDataset").getCurrentItem().countryName)
.limit(1000)
.find()
.then((results) => {
if(results.items.length > 0) {
let allItems = results.items;
console.log(allItems);
while (results.hasNext()) {
let results1 = results.next();
console.log(results1);
allItems = allItems.concat(results1);
}
return allItems;
} else {
// handle case where no matching items found
}
})
.catch((error) => {
let errorMsg = error.message;
let code = error.code;
});
});
});