7.0.2 • Published 4 years ago
@koikorn/list-plugins v7.0.2
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
Option | Type | Default | Description |
---|---|---|---|
createdAtField | String | createdAt | Name of the createdAt field. |
updatedAtField | String | updatedAt | Name of the createdAt field. |
format | String | MM/DD/YYYY h:mm A | Format of the generated DateTime field. |
access | Object | See: access | Change 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
Option | Type | Default | Description |
---|---|---|---|
createdByField | String | createdBy | Name of the createdBy field. |
updatedByField | String | updatedBy | Name of the createdBy field. |
ref | String | User | A reference to the list authenticated items (users). |
access | Object | See: access | Change 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(),
],
});
7.0.2
4 years ago