#[CLOSED] How to Query more than 25 items from the Appwrite Database

14 messages · Page 1 of 1 (latest)

night thistle
#

So I've added this to my query to try and defeat the default 25 item limit:

                        const response = await databases.listDocuments(
                          DATABASE_ID,
                          QUESTION_COLLECTION_ID,
                          [
                            Query.limit(limit),
                            Query.offset(offset)
                          ]
                        );
                        

                        console.log(`📄 Fetched ${response.documents.length} questions (offset ${offset})`);

                      
                        if (response.documents.length === 0) break;
                      
                        allQuestions.push(...response.documents);
                      
                        total = response.total; // Total documents in the collection
                        offset += response.documents.length;
                      
                      } while (offset < total);``` 
Offset is 0 and Limit is 50. 

But I'm still encountering the 25 limit. I've read through the documentation and I've tried implementing different strategies to no avail
night thistle
#

Hey @zinc ruin I'm just wondering if you could help me out with this. Sorry to each asking questions but I think this should be a quick fix

silent zenith
#

All I can suggest is double checking the variables

night thistle
#

Alright, I'll do that thanks man

night thistle
#

Hey @silent zenith I've gone through the code and everything is working fine. But I'm still hitting the default 25 item query limit. I've tried every thing I can think of. Seeing as you have much more experience than me could you suggest any tricks or checks that I could try?

hot echo
#

Can you console log your limit like you are the offset, and are you sure you have more than 25 documents in that collection?

night thistle
#

I'm definitely sure I have much more than 25 doc in my collection

#

I've hard coded in a magic number into my query and I've removed my offset const response = await databases.listDocuments( DATABASE_ID, QUESTION_COLLECTION_ID, [ Query.limit(100), // Query.offset(offset) ] );

zinc ruin
night thistle
#

@zinc ruin Okay

hot echo
#

What version of the SDK are you using?

#

What version of Appwrite are you using

night thistle
#

So it turned out I solved it. I just kept rebuilding and restarting until the changes finally applied. Thanks for all you help Kenny I really appreciate it