@stefgootzen/payload-plugin-versioning
v1.0.2
Published
PayloadCMS plugin that sets up all necessary fields and hooks to enable collection versioning.
Readme
Payload-Plugin-Versioning
PayloadCMS plugin that sets up all necessary fields and hooks to enable collection versioning.
Installation
Run
npm install @stefgootzen/payload-plugin-versioningoryarn add @stefgootzen/payload-plugin-versioning.Add the following to the
pluginsection of the payload config. Use your own collections.
withVersioning({
enabled: true,
relations: [
{
baseSlug: MyBaseCollection.slug,
versionSlug: MyVersionCollection.slug,
},
],
})Payload Compatibility
| Payload | Plugin-Versioning | |---------|-------------------| | 2.x | Compatible | | 3.x | Untested |
Effects
One-to-many relationship management:
- Adds
versionsfield (many) onbasecollection. - Adds
basefield (one) onversioncollection.
Adds cascade behaviour:
- On
versiondelete: Deletesversiononbase. - On
basedelete: Deletes all correspondingversions.
Automatic versioning on versions:
- Adds an automatically incremented
versionNumberfield on version.
Utility for easy version creation:
- Easily create first
versiononbasecreation, like:axios.post(`${url}/api/base`, { ...baseData, version: { ...versionData } })
Why use this instead of build-in versioning?
Payload's build-in versioning is useful when you've got a concept of a (latest) published document. This plugin is for you if versions are supposed to be "published".
