Back

[SOLVED] Query more than 100 documents to get data

  • 0
  • Databases
  • Web
NeoFox
28 May, 2023, 07:56

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

TL;DR
In this support thread, the user is trying to query more than 100 documents to get data for a bar chart. They are using Appwrite version 1.2.0 and want to know if there is a way to bypass the maximum limit of 100. The solution provided is to paginate the data to retrieve all the documents. However, this solution may not work for the user since they are using an older version of Appwrite (1.2.0) and pagination support was added in version 1.3. The user also asks if they are forced to rewrite everything for MongoDB. There is no response to this
Drake
28 May, 2023, 15:18

Are you using Appwrite Cloud?

NeoFox
28 May, 2023, 22:31

No, im hosting it locally on version 1.2.0

Drake
28 May, 2023, 22:33

You'll need to paginate to get all the data. In 1.3 we removed the max limit

NeoFox
28 May, 2023, 22:45

Ok thanks for the help

Drake
28 May, 2023, 23:36

[SOLVED] Query more than 100 documents to get data

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more