This might be a dumb question, but how do I add a limit to a query in access control?
I want to restrict read requests to the latest doc in the collection: If someone calls the GET /api/[collection] endpoint, it should only return the latest doc
I've tried modifying the req object, but without success.
I think it's not a good idea to limit this (and the way you'd go about it is convoluted) in the access control, as the access control will affect local and other operations in payload
I would limit read to only the users you want and then create your own API endpoint
There you have full control over what parameters are available and what gets returned
https://payloadcms.com/docs/rest-api/overview#custom-endpoints
You could do this, but you would have to set a field on the doc i.e. a checkbox and then when a new doc gets created use a hook to find all the docs where it’s checked, update them to unchecked and check the newest one
Star
Discord
online
Get dedicated engineering support directly from the Payload team..