How to bypass Wix's limit (1000) for conditional dropdown?

Hi guys.

Need some help. I’m still new to coding so I can’t see what’s wrong.

I have a database with over 1000 items. I’m currently querying the database, output the results (and removing duplicates) to a conditional dropdown menu (there are 3)

Everything is working fine except I can’t get past Wix’s output limit of 1000 outputs. I have 1200+ entries in a database but I’m displaying them to a menu and filtering out duplicates so really only 30 or so items show in the menu which is fine, but the problem is the output to get those entries before the duplicates are removed is more than 1000 so not all database entries are sent to the results.
I have found codes of how to bypass the 1000 limit method but not for conditional dropdowns that work for me. After putting the code below I still get an output limit of 1000 so 1/4 of my database entries are not being sent to my menu. Can anyone check the code and see whats wrong? I will just put the first part and not the rest of the conditional menus since I’m trying to get the first menu to work first.

So there are 3 dropdown menus, and menu 2 will depending on what menu 1 selection is, and so on. This is working fine just I need to know how to get all the results instead of only the first 1000.
Any help would be greatly appreciated and see what I’m doing wrong with my code below.

The code below only queries the first 1000 lines and sends the results to remove duplicates and then outputs them to the first conditional dropdown. I need to get the entire query to the dropdown box instead of the first 1000 only.

I have just listed the code below for the first box to reduce clutter and the length of code. Any help would be greatly appreciated if it’s something simple I’m missing or it needs to be modified.


import wixData from 'wix-data';

$w.onReady(function () {
getUniqueListFromDatabase();
});
async function getUniqueListFromDatabase() {
     const List1 = await wixData.query("MyItems")
    .limit(1000)
    .ascending("assetType")
    .find()
     const List2 = await wixData.query("MyItems")
    .limit(1000)
    .skip(1000)
    .ascending("assetType")
    .find()
 const mergedLists = List1.items.concat(List2.items)
 const uniqueItems = getUniqueTitles(mergedLists);
//dropdown1
 $w("#myItemsDropDown").options = buildOptions(uniqueItems);
 function getUniqueTitles(items) {
 const titlesOnly = items.map(item => item.assetType);  // don't forget to change this field key
 return [...new Set(titlesOnly)];
        }
 function buildOptions(uniqueList) {
 return uniqueList.map(curr => {
 return { label: curr, value: curr };
            });
        }
    }

Try this one, and tell me if it works…

async function get_bigData() {
   var DB = "MyItems"
   var ColTotal, COLLECTION = []
   var multiplier = 1000
   var countDB = 3

   for (i=0; i<countDB; i++){
        COLLECTION[i] = await wixData.query(DB)
        .limit(multiplier*i)
        .skip(multiplier*(i-1))
        .find();
   if(i>=countDB) {
      ColTotal=COLLECTION[0].items.concat(COLLECTION[1].items).concat(COLLECTION[2].items)}
   }
   return ColTotal;
}

Thank you so much for your help.

I have tried adding it to replace some of the code but I’m getting an
i is not defined on this line:

for ( i = 0 ; i < countDB ; i ++ ){

. How can I declare the i correctly?

I did try to search for it but I’m still not sure.

I’ve tried declaring i with val but i’m not sure how to correctly do it.

You might want to consider using a .distinct() query. See the Example: Remove duplicates from connected dropdown options using distinct() query . By using distinct(), you eliminate the need to filter the results in code.

Thank you for the tips.

It may be working now (the first dropdown box) with the code I’ve adjusted with distinct query. However, I did not finish linking it to the other conditional boxes so hopefully it’s not a problem. I will also try Russian-dima’s method also, so I can learn from it

@irvingdesignui
Sorry my fault! I forgot something…

for(var i=0; i<countDB; i++){.......
async function get_bigData() {
   var DB = "MyItems"
   var ColTotal, COLLECTION = []
   var multiplier = 1000
   var countDB = 3

   for (var i=0; i<countDB; i++){
        COLLECTION[i] = await wixData.query(DB)
        .limit(multiplier*i)
        .skip(multiplier*(i-1))
        .find();
   if(i>=countDB) {
            
  ColTotal=COLLECTION[0].items.concat(COLLECTION[1].items).concat(COLLECTION[2].items)
        console.log(ColTotal)
        }
    }
}