How to increase the limit of a dataset

Hello there, i have spent a lot of time trying to find a way to increase the limit of the dataset more than 1000 … is this possible ? is there any code can do that ? like to allow me to tell the dataset that i want to show like 10,000 items not only 1000 ?

If you want to get the entire DB, you can try something like:

import wixData from 'wix-data';
$w.onReady(function () {
let r1;
wixData.query("CollectionName").limit(1000).find()
.then(r => {
    r1 = r.items;
 return r.totalCount;
})
.then(r => {
let numberOfQueries = Math.ceil(r/1000);
let queries = [];
 for(let i = 1; i < numberOfQueries; i++){       queries.push(wixData.query("CollectionName").limit(1000).skip(i * 1000));
    }
 return Promise.all(queries.map(e => e.find()));
    })
    .then(r => {
        r = r.map(e => e.items);
        r.unshift(r1);
        r = r.flat();
        console.log(r.length);
 //r is the results, you can use it.
    }).catch(err => err);
});

You could also use the built-in results.hasNext() and result.next() functions for the query to get all Items. If there are more items left, you can use these to automatically run the query for the next 1000, until there are no more left. E.g.

import wixData from 'wix-data'

$w.onReady( async function(){
    try{
        const results = await wixData.query("MyDB").find();
        let allItems = results.items; 
        if(results.hasNext()){
        //Checking if there are more that match your query than what was returned.
            while(results.hasNext()){
                //Call the next query for the new results; 
                results = await results.next(); 
                allItems.concat(results.items);
            }
        }
        console.log(allItems);
    }catch(err){
        console.error(err.message);
    }
});

The above code is untested, but I wrote a variant of it for a client site which works, so this should as well.

Hello sir and thank you for your reply, may you tell me please how can i use this code ? should i copy and paste it in the dataset ? if yes, when i click on the dataset which order i should add for it from it’s properties ? can you please explain a bit more ?

Hello sir, i didn’t get what you mean i am really new to coding, if you can explain how this can be done, thank you a lot

@devdesgames This code is for the webpage. Put it in the page code panel, change the collection name to your collection name, and add the code you want to run when you get the results.

@jonatandor35 i guess i understood, i’ll try it, thank you again