diff --git a/docs/configuration/collections.mdx b/docs/configuration/collections.mdx index 6ad9b746d1..9035feb644 100644 --- a/docs/configuration/collections.mdx +++ b/docs/configuration/collections.mdx @@ -30,6 +30,7 @@ It's often best practice to write your Collections in separate files and then im | **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. | | **`defaultSort`** | Pass a top-level field to sort by default in the collection List view. Prefix the name of the field with a minus symbol ("-") to sort in descending order. | | **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`dbName`** | Custom table or collection name depending on the database adapter. Auto-generated from slug if not defined. _\* An asterisk denotes that a property is required._ @@ -59,7 +60,8 @@ export const Orders: CollectionConfig = { #### More collection config examples You can find an assortment -of [example collection configs](https://github.com/payloadcms/public-demo/tree/master/src/payload/collections) in the Public +of [example collection configs](https://github.com/payloadcms/public-demo/tree/master/src/payload/collections) in the +Public Demo source code on GitHub. ### Admin options diff --git a/docs/configuration/globals.mdx b/docs/configuration/globals.mdx index 394068146d..1206d232a7 100644 --- a/docs/configuration/globals.mdx +++ b/docs/configuration/globals.mdx @@ -6,14 +6,18 @@ desc: Set up your Global config for your needs by defining fields, adding slugs keywords: globals, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express --- -Global configs are in many ways similar to [Collections](/docs/configuration/collections). The big difference is that Collections will potentially contain _many_ documents, while a Global is a "one-off". Globals are perfect for things like header nav, site-wide banner alerts, app-wide localized strings, and other "global" data that your site or app might rely on. +Global configs are in many ways similar to [Collections](/docs/configuration/collections). The big difference is that +Collections will potentially contain _many_ documents, while a Global is a "one-off". Globals are perfect for things +like header nav, site-wide banner alerts, app-wide localized strings, and other "global" data that your site or app +might rely on. -As with Collection configs, it's often best practice to write your Globals in separate files and then import them into the main Payload config. +As with Collection configs, it's often best practice to write your Globals in separate files and then import them into +the main Payload config. ## Options | Option | Description | -| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **`slug`** \* | Unique, URL-friendly string that will act as an identifier for this Global. | | **`fields`** \* | Array of field types that will determine the structure and functionality of the data stored within this Global. [Click here](/docs/fields/overview) for a full list of field types as well as how to configure them. | | **`label`** | Text for the name in the Admin panel or an object with keys for each language. Auto-generated from slug if not defined. | @@ -26,6 +30,7 @@ As with Collection configs, it's often best practice to write your Globals in se | **`graphQL.name`** | Text used in schema generation. Auto-generated from slug if not defined. | | **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. | | **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`dbName`** | Custom table or collection name for this global depending on the database adapter. Auto-generated from slug if not defined. _\* An asterisk denotes that a property is required._ @@ -59,26 +64,30 @@ export default Nav #### Global config example -You can find a few [example Global configs](https://github.com/payloadcms/public-demo/tree/master/src/payload/globals) in the Public Demo source code on GitHub. +You can find a few [example Global configs](https://github.com/payloadcms/public-demo/tree/master/src/payload/globals) +in the Public Demo source code on GitHub. ### Admin options -You can customize the way that the Admin panel behaves on a Global-by-Global basis by defining the `admin` property on a Global's config. +You can customize the way that the Admin panel behaves on a Global-by-Global basis by defining the `admin` property on a +Global's config. -| Option | Description | -| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `group` | Text used as a label for grouping collection and global links together in the navigation. | -| `hidden` | Set to true or a function, called with the current user, returning true to exclude this global from navigation and admin routing. | -| `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) | -| `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). | -| `livePreview`| Enable real-time editing for instant visual feedback of your front-end application. [More](/docs/live-preview/overview). | -| `hideAPIURL` | Hides the "API URL" meta field while editing documents within this collection. | +| Option | Description | +|---------------|-----------------------------------------------------------------------------------------------------------------------------------| +| `group` | Text used as a label for grouping collection and global links together in the navigation. | +| `hidden` | Set to true or a function, called with the current user, returning true to exclude this global from navigation and admin routing. | +| `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) | +| `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). | +| `livePreview` | Enable real-time editing for instant visual feedback of your front-end application. [More](/docs/live-preview/overview). | +| `hideAPIURL` | Hides the "API URL" meta field while editing documents within this collection. | ### Preview -Global `admin` options can accept a `preview` function that will be used to generate a link pointing to the frontend of your app to preview data. +Global `admin` options can accept a `preview` function that will be used to generate a link pointing to the frontend of +your app to preview data. -If the function is specified, a Preview button will automatically appear in the corresponding global's Edit view. Clicking the Preview button will link to the URL that is generated by the function. +If the function is specified, a Preview button will automatically appear in the corresponding global's Edit view. +Clicking the Preview button will link to the URL that is generated by the function. **The preview function accepts two arguments:** @@ -113,15 +122,20 @@ export const MyGlobal: GlobalConfig = { ### Access control -As with Collections, you can specify extremely granular access control (what users can do with this Global) on a Global-by-Global basis. However, Globals only have `update` and `read` access control due to their nature of only having one document. To learn more, go to the [Access Control](/docs/access-control/overview) docs. +As with Collections, you can specify extremely granular access control (what users can do with this Global) on a +Global-by-Global basis. However, Globals only have `update` and `read` access control due to their nature of only having +one document. To learn more, go to the [Access Control](/docs/access-control/overview) docs. ### Hooks -Globals also fully support a smaller subset of Hooks. To learn more, go to the [Hooks](/docs/hooks/overview) documentation. +Globals also fully support a smaller subset of Hooks. To learn more, go to the [Hooks](/docs/hooks/overview) +documentation. ### Field types -Globals support all field types that Payload has to offer—including simple fields like text and checkboxes all the way to more complicated layout-building field groups like Blocks. [Click here](/docs/fields/overview) to learn more about field types. +Globals support all field types that Payload has to offer—including simple fields like text and checkboxes all the way +to more complicated layout-building field groups like Blocks. [Click here](/docs/fields/overview) to learn more about +field types. ### TypeScript diff --git a/docs/database/postgres.mdx b/docs/database/postgres.mdx index b641fdd83a..6a47116a04 100644 --- a/docs/database/postgres.mdx +++ b/docs/database/postgres.mdx @@ -37,12 +37,18 @@ export default buildConfig({ ### Options -| Option | Description | -|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `pool` | [Pool connection options](https://orm.drizzle.team/docs/quick-postgresql/node-postgres) that will be passed to Drizzle and `node-postgres`. | -| `push` | Disable Drizzle's [`db push`](https://orm.drizzle.team/kit-docs/overview#prototyping-with-db-push) in development mode. By default, `push` is enabled for development mode only. | -| `migrationDir` | Customize the directory that migrations are stored. | +| Option | Description | +|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `pool` \* | [Pool connection options](https://orm.drizzle.team/docs/quick-postgresql/node-postgres) that will be passed to Drizzle and `node-postgres`. | +| `push` | Disable Drizzle's [`db push`](https://orm.drizzle.team/kit-docs/overview#prototyping-with-db-push) in development mode. By default, `push` is enabled for development mode only. | +| `migrationDir` | Customize the directory that migrations are stored. | +| `logger` | The instance of the logger to be passed to drizzle. By default Payload's will be used. | | `schemaName` | A string for the postgres schema to use, defaults to 'public'. | +| `localesSuffix` | A string appended to the end of table names for storing localized fields. Default is '_locales'. | +| `relationshipsSuffix` | A string appended to the end of table names for storing relationships. Default is '_rels'. | +| `versionsSuffix` | A string appended to the end of table names for storing versions. Defaults to '_v'. | + + ### Access to Drizzle diff --git a/docs/fields/array.mdx b/docs/fields/array.mdx index 18dab76efb..f735fdf92a 100644 --- a/docs/fields/array.mdx +++ b/docs/fields/array.mdx @@ -12,22 +12,24 @@ keywords: array, fields, config, configuration, documentation, Content Managemen **Example uses:** - A "slider" with an image ([upload field](/docs/fields/upload)) and a caption ([text field](/docs/fields/text)) -- Navigational structures where editors can specify nav items containing pages ([relationship field](/docs/fields/relationship)), an "open in new tab" [checkbox field](/docs/fields/checkbox) -- Event agenda "timeslots" where you need to specify start & end time ([date field](/docs/fields/date)), label ([text field](/docs/fields/text)), and Learn More page [relationship](/docs/fields/relationship) +- Navigational structures where editors can specify nav items containing + pages ([relationship field](/docs/fields/relationship)), an "open in new tab" [checkbox field](/docs/fields/checkbox) +- Event agenda "timeslots" where you need to specify start & end time ([date field](/docs/fields/date)), + label ([text field](/docs/fields/text)), and Learn More page [relationship](/docs/fields/relationship) ### Config | Option | Description | -| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | | **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. | | **`fields`** \* | Array of field types to correspond to each row of the Array. | @@ -45,15 +47,17 @@ keywords: array, fields, config, configuration, documentation, Content Managemen | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). | | **`custom`** | Extension point for adding custom data (e.g. for plugins) | | **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | +| **`dbName`** | Custom table name for the field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | _\* An asterisk denotes that a property is required._ ### Admin Config -In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following properties: +In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following +properties: | Option | Description | -| ------------------------- | -------------------------------------------------------------------------------------------------------------------- | +|---------------------------|----------------------------------------------------------------------------------------------------------------------| | **`initCollapsed`** | Set the initial collapsed state | | **`components.RowLabel`** | Function or React component to be rendered as the label on the array row. Receives `({ data, index, path })` as args | diff --git a/docs/fields/blocks.mdx b/docs/fields/blocks.mdx index ac5540ace1..1991900ea6 100644 --- a/docs/fields/blocks.mdx +++ b/docs/fields/blocks.mdx @@ -14,22 +14,23 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme **Example uses:** -- A layout builder tool that grants editors to design highly customizable page or post layouts. Blocks could include configs such as `Quote`, `CallToAction`, `Slider`, `Content`, `Gallery`, or others. +- A layout builder tool that grants editors to design highly customizable page or post layouts. Blocks could include + configs such as `Quote`, `CallToAction`, `Slider`, `Content`, `Gallery`, or others. - A form builder tool where available block configs might be `Text`, `Select`, or `Checkbox`. - Virtual event agenda "timeslots" where a timeslot could either be a `Break`, a `Presentation`, or a `BreakoutSession`. ### Field config | Option | Description | -| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | | **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. | | **`blocks`** \* | Array of [block configs](/docs/fields/blocks#block-configs) to be made available to this field. | @@ -51,10 +52,11 @@ _\* An asterisk denotes that a property is required._ ### Admin Config -In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following properties: +In addition to the default [field admin config](/docs/fields/overview#admin-config), you can adjust the following +properties: | Option | Description | -| ------------------- | ------------------------------- | +|---------------------|---------------------------------| | **`initCollapsed`** | Set the initial collapsed state | ### Block configs @@ -72,7 +74,7 @@ Blocks are defined as separate configs of their own. | Option | Description | -| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **`slug`** \* | Identifier for this block type. Will be saved on each block as the `blockType` property. | | **`fields`** \* | Array of fields to be stored in this block. | | **`labels`** | Customize the block labels that appear in the Admin dashboard. Auto-generated from slug if not defined. | @@ -80,7 +82,8 @@ Blocks are defined as separate configs of their own. | **`imageAltText`** | Customize this block's image thumbnail alt text. | | **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). | | **`graphQL.singularName`** | Text to use for the GraphQL schema name. Auto-generated from slug if not defined. NOTE: this is set for deprecation, prefer `interfaceName`. | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`dbName`** | Custom table name for this block type when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from slug if not defined. +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | #### Auto-generated data per block @@ -92,7 +95,8 @@ The `blockType` is saved as the slug of the block that has been selected. **`blockName`** -The Admin panel provides each block with a `blockName` field which optionally allows editors to label their blocks for better editability and readability. +The Admin panel provides each block with a `blockName` field which optionally allows editors to label their blocks for +better editability and readability. ### Example @@ -139,7 +143,8 @@ export const ExampleCollection: CollectionConfig = { ### TypeScript -As you build your own Block configs, you might want to store them in separate files but retain typing accordingly. To do so, you can import and use Payload's `Block` type: +As you build your own Block configs, you might want to store them in separate files but retain typing accordingly. To do +so, you can import and use Payload's `Block` type: ```ts import type { Block } from 'payload/types' diff --git a/docs/fields/radio.mdx b/docs/fields/radio.mdx index b22ab2d3fc..aa7d57d9db 100644 --- a/docs/fields/radio.mdx +++ b/docs/fields/radio.mdx @@ -36,6 +36,7 @@ keywords: radio, fields, config, configuration, documentation, Content Managemen | **`required`** | Require this field to have a value. | | **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). | | **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`enumName`** | Custom enum name for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. _\* An asterisk denotes that a property is required._ diff --git a/docs/fields/select.mdx b/docs/fields/select.mdx index bc0d7c0a78..250676cf5f 100644 --- a/docs/fields/select.mdx +++ b/docs/fields/select.mdx @@ -12,32 +12,34 @@ keywords: select, multi-select, fields, config, configuration, documentation, Co ### Config -| Option | Description | -| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | -| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing a `label` string and a `value` string. | -| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many selections instead of only one. | -| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. | -| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | -| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) | -| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | -| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. | -| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) | -| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) | -| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. | -| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | -| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | -| **`required`** | Require this field to have a value. | -| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. | -| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| Option | Description | +|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) | +| **`options`** \* | Array of options to allow the field to store. Can either be an array of strings, or an array of objects containing a `label` string and a `value` string. | +| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many selections instead of only one. | +| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. | +| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. | +| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) | +| **`index`** | Build an [index](/docs/database/overview) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. | +| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. | +| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) | +| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) | +| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. | +| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) | +| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. | +| **`required`** | Require this field to have a value. | +| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. | +| **`custom`** | Extension point for adding custom data (e.g. for plugins) | +| **`enumName`** | Custom enum name for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | +| **`dbName`** | Custom table name (if `hasMany` set to `true`) for this field when using SQL database adapter ([Postgres](/docs/database/postgres)). Auto-generated from name if not defined. | _\* An asterisk denotes that a property is required._ @@ -52,7 +54,8 @@ _\* An asterisk denotes that a property is required._ ### Admin config -In addition to the default [field admin config](/docs/fields/overview#admin-config), the Select field type also allows for the following admin-specific properties: +In addition to the default [field admin config](/docs/fields/overview#admin-config), the Select field type also allows +for the following admin-specific properties: **`isClearable`** @@ -60,7 +63,8 @@ Set to `true` if you'd like this field to be clearable within the Admin UI. **`isSortable`** -Set to `true` if you'd like this field to be sortable within the Admin UI using drag and drop. (Only works when `hasMany` is set to `true`) +Set to `true` if you'd like this field to be sortable within the Admin UI using drag and drop. (Only works +when `hasMany` is set to `true`) ### Example @@ -101,7 +105,8 @@ export const ExampleCollection: CollectionConfig = { ### Customization -The Select field UI component can be customized by providing a custom React component to the `components` object in the Base config. +The Select field UI component can be customized by providing a custom React component to the `components` object in the +Base config. ```ts export const CustomSelectField: Field = { @@ -156,27 +161,33 @@ export const CustomSelectComponent: React.FC = ({ path, optio return (
- - setValue(e.value)} - /> -
- ) +