7.0.2 • Published 4 years ago

@koikorn/list-plugins v7.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

List Plugins

atTracking

Adds createdAt and updatedAt fields to a list. These fields are read-only by will be updated automatically when items are created or updated.

Usage

const { atTracking } = require('@koikorn/list-plugins');

keystone.createList('ListWithPlugin', {
  fields: {
    // ...
  },
  plugins: [
    atTracking({
      /* ...config */
    }),
  ],
});

Config

OptionTypeDefaultDescription
createdAtFieldStringcreatedAtName of the createdAt field.
updatedAtFieldStringupdatedAtName of the createdAt field.
formatStringMM/DD/YYYY h:mm AFormat of the generated DateTime field.
accessObjectSee: accessChange default access controls.

access

By default access control on at tracking fields is read only:

{
  read: true,
  create: false,
  update: false
}

Disabling created or updated

You can import either createdAt or updatedAt to apply a single tracking field:

const { createdAt, updatedAt } = require('@koikorn/list-plugins');

Note: The API is the same.

byTracking

Adds createdBy and updatedBy fields to a list. These fields are read-only by will be updated automatically when items are created or updated.

Usage

const { byTracking } = require('@koikorn/list-plugins');

keystone.createList('ListWithPlugin', {
  fields: {
    // ...
  },
  plugins: [
    byTracking({
      /* ...config */
    }),
  ],
});

Config

OptionTypeDefaultDescription
createdByFieldStringcreatedByName of the createdBy field.
updatedByFieldStringupdatedByName of the createdBy field.
refStringUserA reference to the list authenticated items (users).
accessObjectSee: accessChange default access controls.

access

By default access control on at tracking fields is read only:

{
  read: true,
  create: false,
  update: false
}

Disabling created or updated

You can import either createdBy or updatedBy to apply a single tracking field:

const { createdBy, updatedBy } = require('@koikorn/list-plugins');

Note: The API is the same.

singleton

This plugin makes a list singleton by allowing only one item in the list. Useful for list which must contain only one items.

Usage

const { singleton } = require('@koikorn/list-plugins');

keystone.createList('ListWithPlugin', {
  fields: {...},
  plugins: [
    singleton(),
  ],
});