How to get a timeline of versions?

default discord avatar
moritz
8 months ago
1

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?

  • discord user avatar
    patrikkozak
    Payload Team
    8 months ago

    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#versions

    Let me know if you have any other questions!

    versions-of-specific-doc.png
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.