Skip to content
Back

Pagination, count of pages

  • 0
  • Databases
  • Flutter
  • General
pitcairn1987
12 May, 2023, 12:36

I wanted to implement pagination in my application. As I understand it, for scrolling pagination I should use "Cursor pagination", which is a nicer solution in most cases. However, in my application, I need the ability for the user to "jump" a few pages further. So if I understand correctly I should use:" Offset pagination". However, I have a problem understanding how to display the number of available pages before. Is there any way to get the amount of all the documents in the collection without downloading them first?

TL;DR
To get the count of all documents in a collection without downloading them, you can maintain a count in a separate metadata collection. Alternatively, you can use the "list documents" function with a high limit and select a small attribute, then check the length of the documents. This method may get slower as the count of documents increases. For implementing pagination, if you need the ability for users to jump ahead a few pages, "Offset pagination" is recommended. However, it is unclear how to display the number of available pages beforehand. Unfortunately, the support thread does not provide a solution for this issue.
Drake
12 May, 2023, 16:53

Is there any way to get the amount of all the documents in the collection without downloading them first?

I would suggest maintaining this count yourself in a metadata collection.

Otherwise, for now, you can use list documents, pass a really high limit, and select a single small attribute. Then, check the length of documents. The problem with this is it will get slower as the count gets higher

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