I'm looking to implement the version restore function programmatically.
Having gone over the Version documentation herehttps://payloadcms.com/docs/versions/overview#version-operations
I am still missing quite a lot of information on how that works, e.g which version it restores to, what exactly is the ID field, etc.
Is there more in-depth documentation on these LocalAPIs?
The endpoints follow your typical REST crud pattern. The typical process would be to list the versions first via
then perform a restore with
to the specific
you want to restore. The
being the unique identifier for the version that you'd like to restore.
What can I help clarify beyond that?
Thank you for that, this is clear. I'm thinking how versions get created, at which point exactly and are the objects in the _versions table (mongo collection) always a version behind or does _versions maintain an exact replica of what is in the main table.
I ask this because I want to restore to a previous version (exactly one save behind) and so should I select the last version doc or one before that as the last one is a replica of the current one.
The versions endpoint will return previous versionsand the latest
The query against the versions endpoint would look something like this:
. You can also open up your Network tab while browsing around the Versions page in the Admin UI to see this.
I don't recall if they're strictly ordered on the response, so you could also pass in something like
to sort the response.