Hello,
I have a Code which works like a charm and gets all information of my database I need to display on my repeater.
However, the limit(1000) function is only checking up to 1000 lines in my database and does not include the rest.
I already found out that I need to include the next() and has next () function into my code.
But no matter how I do it I´m not able to make it running for all my database lines.
My code (without next() and has next(), that works perfect till limit(1000):
import wixUsers from 'wix-users'; import wixData from 'wix-data'; $w.onReady(function () { $w('#PartnerOverview').onReady(() => { let user = wixUsers.currentUser; let userId = user.id; let itemUser = $w('#PrivateMember').getCurrentItem()._id; if (userId === itemUser) { $w("#listRepeater").onItemReady(($item, itemData, index) => { }); wixData.query('PartnerOverview') .eq("copyOwner", userId) .descending("datumReverse") .limit(1000) .find() .then((results) => { if (results.totalCount > 0) { $w('#listRepeater').data = Array.from(results.items.reduceRight((m, t) => m.set(t.monat, t), new Map()).values()).reverse(); $w('#repeater2').data = Array.from(results.items.reduceRight((m, t) => m.set(t.besuchtesRestaurant, t), new Map()).values()).reverse(); } else { $w('#listRepeater').hide(); $w('#repeater2').hide(); $w('#SammelnInfo').show(); } }) .catch((error) => { console.error(error); }); $w('#SammelnInfo').hide(); } }); }); Now I want to include this Code (with next () and has next()) to check for the hole data: async function retrieveAllItems() { 2 let results = await wixData.query("myCollection") 3 .limit(1000) 4 .find(); 5 let allItems = results.items; 6 while (results.hasNext()) { 7 results = await results.next(); 8 allItems = allItems.concat(results.items); 9 } 10 return allItems; 11}
My main issue is to include this code into the code above, while maintaining the .then () function of my Code above.
Any ideas? Thanks
Probably the Experts do have an idea: @Velo-Ninja
@anthonyb
Hello Anyone found the solution i am also facing this in my website
https://fontsbunch.com/
If you want to select the next 1000 records you should set the select parameter to 1000 and the skip parameter to 1000, which will return records 1001 to 2000. You should continue to do this until 0 records are returned to retrieve the whole data set HCA Rewards
Can you find solution?
Has anyone tried putting subsequent .next calls in a recursively-called function?
I tried this with non-async calls. Seems to work, but I suspect it is poor form. Here goes anyway :
__ // declare a global var for results
__ // fetch first batch of results
.then(results => {recursiveCall(results)}); // (Pass the promise to the function, not the items.)
export function recursiveCall(pwomith) {
__ // Add pwomith.items to global variable
if (pwomith.hasNext()) {
pwomith.next()
.then(results => {recursiveCall(results)});
}
else
{ __ } // populate the elements from the global variable
}
Fascinated you are using over 1000 items in a repeater though! Best of luck.
Chas