@stefgootzen/payload-plugin-versioning
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Payload-Plugin-Versioning

PayloadCMS plugin that sets up all necessary fields and hooks to enable collection versioning.

Installation

  1. Run npm install @stefgootzen/payload-plugin-versioning or yarn add @stefgootzen/payload-plugin-versioning.

  2. 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) on base collection.
  • Adds base field (one) on version collection.

Adds cascade behaviour:

  • On version delete: Deletes version on base.
  • On base delete: Deletes all corresponding versions.

Automatic versioning on versions:

  • Adds an automatically incremented versionNumber field on version.

Utility for easy version creation:

  • Easily create first version on base 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".

Package Sidebar

Install

npm i @stefgootzen/payload-plugin-versioning

Weekly Downloads

13

Version

0.0.6

License

MIT

Unpacked Size

40.2 kB

Total Files

21

Last publish

Collaborators

  • stefgootzen