Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

How to get a timeline of versions?

default discord avatar
moritzlast year
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
    last year

    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
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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