Back

How to get a document by index?

  • 0
  • Databases
memoonlite
27 Nov, 2023, 15:16

Hi! πŸ‘‹πŸ»

I have like 800 documents in a collection. Let's say I'd like to get the document at index 271, without having to retrieve all documents. Is that possible by using built in Appwrite SDK functionality? Or should a make an integer attribute storing an index number?

Thanks for reading! 😊

TL;DR
The user wants to know if they can retrieve a document by index in Appwrite without retrieving all the documents. It is mentioned that Appwrite does not use an incrementing id for documents. The user is advised to add their own id column and use a function to set that column on document insertion. They can then put an index on that column to filter down to it using Appwrite queries.
Kenny
27 Nov, 2023, 15:26

I don't believe appwrite uses an incrementing id for the documents. So there wouldn't be a way to get the 271st document out of the box. You can add your own id column and use something like a function to set that column on document insertion. You can then put an index on that column so you can filter down to it using appwrite queries.

memoonlite
27 Nov, 2023, 15:29

Thanks for confirming! πŸ‘πŸ» I thought maybe I'm overlooking something. I'll go that route. 😊

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