I have a collection that uses
versions
and
drafts
. This collection has a field
updatedAt
.
I want to display to the user the
updatedAt
field of the the 3 versions leading up to the currently published versions.
Basicly I want to show to the user a list like this
<ul>
<li>Updated Mar 12 by X</li>
<li>Updated Mar 15 by Y</li>
<li>Updated Mar 16 by Z</li>
</ul>
whats the best way to get this data?
Hey @moritz - you can do this by fetching to your rest api to the versions collection per your specific document.
Your api endpoint would look like this:
/api/{collectionSlug}/versions?where[parent][equals]=id_of_main_doc
I've attached an image showing what this query would return
You can also find more information on what you can do with versions here:
https://payloadcms.com/docs/versions/overview#versionsLet me know if you have any other questions!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.