Loop Code return difference result between editor and Published site.

Hello World, I have a loop function for query for result in database then insert the queried result to another database. The editor work just fine but the published site return difference result. Like this.


export function button1_click(event) {
//this query for row that size = 1
let size = 1 ;
console.log(size);
wixData.query( “depandrole2021” )
.eq( “productionSize” , size)
.limit( 1000 )
.find()

    .then((results) => { 

if (results.items.length > 0 ) {
let size2 = results.items;

//then make loop here

for ( let i = 0 ; i <= size2.length; i++) {

let toINSERT = {

“depCode” : size2[i].departmentCode,
“department” : size2[i].department,
“role” : size2[i].role,
“roleCode” : size2[i].budgetCode,
“type” : size2[i].type,

                } 

       wixData.insert( "projectBudget" , toINSERT) 

            } 

        } 
    }) 

}


The the sandbox database return 48 items as expect.


:smiley:
But the published data return just 30 items every time.


:sweat:


I’m looking for solutions like async/await function but it quite complicate to understand.
Anyone here can give me the solution please get me out of this trouble.
Many Thanks for advance.
:grinning:

Hi Chookiat,

Just to verify, are your Sandbox and Live databases synced with exactly the same data?

@derekmoorer Yes, All the data are exactly the same. Even I do the query + count it show the same number. But not the insert operation.