Code extention with limit(1000) - next() and has next() function to get all database entries and display on repeater

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

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

Hi Chas,

no I do not want the repeater to return over 1000 items.
I want that my database is checked for all data, which are relevant for that user and not only 1000 lines.

Before I had a limit(50) parameter and my repeater showed only 2 elements.
After I changed it to limit(1000) it showed all. (which where 3 elements in this case)

Hello Anyone found the solution i am also facing this in my website

https://fontsbunch.com/

Probably the Experts do have an idea:
@russian-dima
@tony-brunsman