i want to randomise
i am trying to get random documents in batches and would want to not less repeated documents. just like instagram reels
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-endpointsThen 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?
So the batches themselves should be de-duped?
You could make a feature request on the repository to add that!
Is this still the best way to do it? 🙂 Shouldn't something like
sort: 'RANDOM()',
be a nice thing?
You're right Let's try that! 💪
Star
Discord
online
Get dedicated engineering support directly from the Payload team.