@stefgootzen/payload-plugin-versioning
v0.0.6
Published
PayloadCMS plugin that sets up all necessary fields and hooks to enable collection versioning.
Downloads
86
Maintainers
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-versioning
oryarn add @stefgootzen/payload-plugin-versioning
.Add the following to the
plugin
section 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
versions
field (many) onbase
collection. - Adds
base
field (one) onversion
collection.
Adds cascade behaviour:
- On
version
delete: Deletesversion
onbase
. - On
base
delete: Deletes all correspondingversions
.
Automatic versioning on versions:
- Adds an automatically incremented
versionNumber
field on version.
Utility for easy version creation:
- Easily create first
version
onbase
creation, 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".