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 };
});
}
}