Back

Database | can't use pagination together with attribute sorting

  • 0
  • Flutter
Cartok
13 Dec, 2023, 15:29

I get the error "Could not get documents from database" after some requests, when trying to query some documents with order and by cursor. Does anyone else experience this?

TL;DR
The developer is having trouble using pagination and attribute sorting together in the database. They are asking if the last document ID and page size are correct. They mention a "general_unknown" error, but don't provide further details.
D5
13 Dec, 2023, 18:36

What's the code or queries?

Cartok
14 Dec, 2023, 15:13

Looks like this

TypeScript
response = await database.listDocuments(
  databaseId: Database.databaseId,
  collectionId: Database.notesCollectionId,
  queries: [
    Query.limit(pageSize),
    if (lastDocumentId != null) Query.cursorAfter(lastDocumentId!),
    Query.orderDesc('tier'),
    Query.orderAsc('index'),
  ],
);
Cartok
14 Dec, 2023, 15:14

I have two attributes I use to sort on. Tier is string (S,A,B,C,D), and index is a number

Drake
14 Dec, 2023, 15:46

and can you share the full error?

Cartok
12 Jan, 2024, 17:03

Hi @Drake I was a long time away, I am sorry not having read and answered. It is a general_unknown error. This is all I can see:

Cartok
12 Jan, 2024, 17:04
D5
12 Jan, 2024, 18:02

Are you sure the last doc ID is correct and pagesize?

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