Web Developer
Hi I am trying to get data so that i can use a bar chart to display how many times a document with the same "name" attribute exists. However I have realised that for this to work I need to bypass the Query.limit(100) maximum limit since i may need to query up to 500 documents. Is there a way I can implement this where it will still work well in production? or am i just forced to rewrite everything for MongoDB. this is the code i have: ```const getDefaultData = async () => {
const res = await databases.listDocuments(databaseID, 'default_data',[
Query.equal('user', [userID]),
Query.orderDesc("name"),
Query.limit("100") // the default limit is 25 so i have to use this to get all the data but even 100 is not enough
]);
// this gets the count of the items
const nameCounts = res.documents.reduce((acc, obj) => {
acc[obj.name] = (acc[obj.name] || 0) + 1;
return acc;
}, {});
const topDefaultData = Object.entries(nameCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 5)
.map(([name, count]) => ({ name, count }));
return topDefaultData;
}```