[RESOLVED] Exceed query limit 1k

Hi everyone,
I am creating a filter for Italian region, province and city starting from a periodically updated file.
Two of the 21 regions have more than 1000 cities, which is beyond the wixData.query limit.
I found a solution in a forum post, I implemented it, but it doesn’t seem to exceed the limit because it calculates all the other regions, except the two with too many records.

I post my code here, could you please give me suggestions?
Thank you!

export function fldRegion_change ( event ) {
$w ( “#fldCountry” ). disable ()
let value = $w ( “#fldRegion” ). value ; // then dorpdown button where choose a region)
let res ;
res = calcCountry ( value ) // function below
. then (( res ) => {
let country = getTopicVoice ( res );
$w ( “#fldCountry” ). options = buildOptions ( country );

// function to have only one single voice instead of more 1000 voice into the dropdown button
function getTopicVoice ( items ) { .
let singleCountry = items . map ( item => item . province );
return [… new Set ( singleCountry )];
}

        **function**  buildOptions ( uniqueList ) { 
            **return**  uniqueList . map ( curr  => { 
                **return**  {  label :  curr ,  value :  curr  }; 
            }); 
        } 
    }) 
    . then (() => {  $w ( "#fldCountry" ). enable () }) 

}

// this is the code found in other post and adapted by me
export function calcCountry ( value ) {
return wixData . query ( “TerritoryItaly” ). limit ( 1000 ). eq ( “region” , value ). find (). then ( async result => {
let all_items = ;
all_items = all_items . concat ( result . items );
while ( result . hasNext ()) {
let temp = await result . next ();
all_items = all_items . concat ( temp . items );
}
return all_items ;
})

The calcCountry should do the work.

By the way, if you use .distinct(’ province’ ) instead of .find() in the calcCountry function, you’ll be able to skip the getTopicVoice function.

Thank you very much J.D.!
Your advice has fully solved my problem!