Back

[SOLVED] the query only retuns 25 items from the database

  • 0
  • Databases
  • Web
Rocky Essel
31 May, 2023, 03:32
TypeScript
    const data = (await db.listDocuments(
      import.meta.env.VITE_APPWRITE_DATABASE_ID,
      import.meta.env.VITE_APPWRITE_COLLECTION_ID,
      [Query.equal('userId', [userId])]
    )) as unknown as { total: number; documents: UserDocumentProps[] | [] };
    return data;
  };```

in the console.log() it shows that the number of items is more than 70, but are only getting 25, and i have not limited anything from my side of the code, but i created a new account then uploaded a lot of files, and once it passes 25 the rest doesn't show. So someone help me this problem before i have  to go class?
TL;DR
The user is experiencing an issue where their query only returns 25 items from the database, even though there are more than 70 items. They are using the Appwrite platform and have not set any limitations on their side. They are concerned because changing the design to implement pagination would not work for their use case. There is a solution provided by another user in the thread stating that it is always a good design choice to have pagination in mind when working with data endpoints. It is suggested to specify the number of records to fetch instead of leaving it unspecified. The default limit is 25, and the user can refer to the Appwrite documentation
Drake
31 May, 2023, 03:35

The default limit is 25. See https://appwrite.io/docs/pagination

Rocky Essel
31 May, 2023, 03:38

Okay thank you, but in my use case, can't i make it limitless, becuase the file i been grouped into sections, meaning so making it into pagination means i have to change the design

Drake
31 May, 2023, 03:39

You should always design with pagination in mind

Rocky Essel
31 May, 2023, 04:06

Okay thank you

Drake
31 May, 2023, 04:13

[SOLVED] the query only retuns 25 items from the database

VincentGe
31 May, 2023, 18:48

For anyone else searching this page into the future, returning and unspecified amount of data from any endpoint is a terrible design choice.

You could accidentally try to return, say, 200 million records (probably in the terabyte range?), essentially DoS attacking your own server, and your own app.

Even if there's no reason for there to be large data set, someone could notice this, and maliciously create data in the collection to cause this issue.

If you revoked create access, and know there will be only 1000 records, for example, then just specify fetching 1000 records.

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