Back

How can I randomly retrieve one document from a collection without fetching all documents?

  • 0
  • Databases
  • Web
LessUse
26 Oct, 2023, 14:31

hey guys i made a appwrite database and i add my documents with relevant attributes in a collection, now is there any way to get randomly one of the document in a collection like without fetching all the documents id and then select one of the document. like it made the process slower if the no. of documents is many

TL;DR
The user is asking if there is a way to retrieve a random document from a collection without fetching all the documents. They mention that the current maximum limit for getting documents is 100. There is a suggested workaround mentioned in the thread, but it is not clear if it works. The user also suggests upvoting an issue related to this feature on GitHub. The solution is not provided in the thread.
Binyamin
26 Oct, 2023, 14:34

This feature is not yet implemented

Maniac_Fighter
26 Oct, 2023, 14:34

You might wanna upvote this issue

LessUse
26 Oct, 2023, 14:34

so i have to first retreive all the documents, then randomly get one, right?

Binyamin
26 Oct, 2023, 14:35

Yes

LessUse
26 Oct, 2023, 14:35

sad

Binyamin
26 Oct, 2023, 14:35

Also there's some work around

LessUse
26 Oct, 2023, 14:35

upvote done

Binyamin
26 Oct, 2023, 14:35

Check this

Binyamin
26 Oct, 2023, 14:36

Meaning you add another counter ID and randomly select it It's a bit tricky, but should work

LessUse
26 Oct, 2023, 14:37

also, what is the maximum limit to get documents?, its 100?

Binyamin
26 Oct, 2023, 14:37

Now you can go up to 5K

LessUse
26 Oct, 2023, 14:38

ok 5k will be enough for me

LessUse
26 Oct, 2023, 14:38

thanks

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