#Is it possible to get a random document?
10 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
Not out of the box, but you could add a custom endpoint to your collection and do some custom logic in it. https://payloadcms.com/docs/rest-api/overview#custom-endpoints
Then use req.payload with the local API, get totalDoc count, then do something creative with pagination/limit.
Maybe limit: 1 and page: randomIntInTotalDocRange
Is it possible to get a random document?
i am trying to get random documents in batches and would want to not less repeated documents. just like instagram reels
So the batches themselves should be de-duped?
Is this still the best way to do it? 🙂 Shouldn't something like sort: 'RANDOM()', be a nice thing?
You could make a feature request on the repository to add that!