docs: fix incorrect mdx (#10201)
This commit is contained in:
@@ -122,7 +122,7 @@ export const CollectionWithReadAccess: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
Return a [Query](../queries/overview) to limit the Documents to only those that match the constraint. This can be helpful to restrict users' access to specific Documents. [More details](../queries/overview).
|
Return a [Query](../queries/overview) to limit the Documents to only those that match the constraint. This can be helpful to restrict users' access to specific Documents. [More details](../queries/overview).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ export const CollectionWithUpdateAccess: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
Return a [Query](../queries/overview) to limit the Documents to only those that match the constraint. This can be helpful to restrict users' access to specific Documents. [More details](../queries/overview).
|
Return a [Query](../queries/overview) to limit the Documents to only those that match the constraint. This can be helpful to restrict users' access to specific Documents. [More details](../queries/overview).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const FieldWithAccessControl: Field = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
Field Access Controls does not support returning [Query](../queries/overview) constraints like [Collection Access Control](./collections) does.
|
Field Access Controls does not support returning [Query](../queries/overview) constraints like [Collection Access Control](./collections) does.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const defaultPayloadAccess = ({ req: { user } }) => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
In the [Local API](../local-api/overview), all Access Control is _skipped_ by default. This allows your server to have full control over your application. To opt back in, you can set the `overrideAccess` option to `false` in your requests.
|
In the [Local API](../local-api/overview), all Access Control is _skipped_ by default. This allows your server to have full control over your application. To opt back in, you can set the `overrideAccess` option to `false` in your requests.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ The Admin Panel responds dynamically to your changes to Access Control. For exam
|
|||||||
To accomplish this, Payload exposes the [Access Operation](../authentication/operations#access). Upon login, Payload executes each Access Control function at the top level, across all Collections, Globals, and Fields, and returns a response that contains a reflection of what the currently authenticated user can do within your application.
|
To accomplish this, Payload exposes the [Access Operation](../authentication/operations#access). Upon login, Payload executes each Access Control function at the top level, across all Collections, Globals, and Fields, and returns a response that contains a reflection of what the currently authenticated user can do within your application.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
When your access control functions are executed via the [Access Operation](../authentication/operations#access), the `id` and `data` arguments will be `undefined`. This is because Payload is executing your functions without referencing a specific Document.
|
When your access control functions are executed via the [Access Operation](../authentication/operations#access), the `id` and `data` arguments will be `undefined`. This is because Payload is executing your functions without referencing a specific Document.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ The following options are available:
|
|||||||
| **`views`** | Override or create new views within the Admin Panel. [More details](./views). |
|
| **`views`** | Override or create new views within the Admin Panel. [More details](./views). |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
For details on how to build Custom Components, see [Building Custom Components](./components#building-custom-components).
|
For details on how to build Custom Components, see [Building Custom Components](./components#building-custom-components).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ preview: (doc, { req }) => `${req.protocol}//${req.host}/${doc.slug}` // highlig
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
For fully working example of this, check of the official [Draft Preview Example](https://github.com/payloadcms/payload/tree/main/examples/draft-preview) in the [Examples Directory](https://github.com/payloadcms/payload/tree/main/examples).
|
For fully working example of this, check of the official [Draft Preview Example](https://github.com/payloadcms/payload/tree/main/examples/draft-preview) in the [Examples Directory](https://github.com/payloadcms/payload/tree/main/examples).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -177,6 +177,6 @@ export const Posts: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
If you are adding `listSearchableFields`, make sure you index each of these fields so your admin queries can remain performant.
|
If you are adding `listSearchableFields`, make sure you index each of these fields so your admin queries can remain performant.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ The Payload [Admin Panel](./overview) is designed to be as minimal and straightf
|
|||||||
All Custom Components in Payload are [React Server Components](https://react.dev/reference/rsc/server-components) by default. This enables the use of the [Local API](../local-api/overview) directly on the front-end. Custom Components are available for nearly every part of the Admin Panel for extreme granularity and control.
|
All Custom Components in Payload are [React Server Components](https://react.dev/reference/rsc/server-components) by default. This enables the use of the [Local API](../local-api/overview) directly on the front-end. Custom Components are available for nearly every part of the Admin Panel for extreme granularity and control.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
Client Components continue to be fully supported. To use Client Components in your app, simply include the `use client` directive. Payload will automatically detect and remove all default, [non-serializable props](https://react.dev/reference/rsc/use-client#serializable-types) before rendering your component. [More details](#client-components).
|
Client Components continue to be fully supported. To use Client Components in your app, simply include the `use client` directive. Payload will automatically detect and remove all default, [non-serializable props](https://react.dev/reference/rsc/use-client#serializable-types) before rendering your component. [More details](#client-components).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ const config = buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
All Custom Components can be either Server Components or Client Components, depending on the presence of the `use client` directive at the top of the file.
|
All Custom Components can be either Server Components or Client Components, depending on the presence of the `use client` directive at the top of the file.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ Each Custom Component receives the following props by default:
|
|||||||
| `i18n` | The [i18n](../configuration/i18n) object. |
|
| `i18n` | The [i18n](../configuration/i18n) object. |
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
All Custom Components also receive various other props that are specific component being rendered. See [Root Components](#root-components), [Collection Components](./collections#custom-components), [Global Components](./globals#custom-components), or [Field Components](./fields#custom-components) for a complete list of all default props per component.
|
All Custom Components also receive various other props that are specific component being rendered. See [Root Components](#root-components), [Collection Components](./collections#custom-components), [Global Components](./globals#custom-components), or [Field Components](./fields#custom-components) for a complete list of all default props per component.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ export const MyClientComponent: React.FC = () => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
Client Components cannot be passed [non-serializable props](https://react.dev/reference/rsc/use-client#serializable-types). If you are rendering your Client Component _from within_ a Server Component, ensure that its props are serializable.
|
Client Components cannot be passed [non-serializable props](https://react.dev/reference/rsc/use-client#serializable-types). If you are rendering your Client Component _from within_ a Server Component, ensure that its props are serializable.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -455,7 +455,7 @@ Payload also exports its [SCSS](https://sass-lang.com) library for reuse which i
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
You can also drill into Payload's own component styles, or easily apply global, app-wide CSS. More on that [here](./customizing-css).
|
You can also drill into Payload's own component styles, or easily apply global, app-wide CSS. More on that [here](./customizing-css).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -503,7 +503,7 @@ The following options are available:
|
|||||||
| **`views`** | Override or create new views within the Admin Panel. [More details](./views). |
|
| **`views`** | Override or create new views within the Admin Panel. [More details](./views). |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
You can also use set [Collection Components](./collections#custom-components) and [Global Components](./globals#custom-components) in their respective configs.
|
You can also use set [Collection Components](./collections#custom-components) and [Global Components](./globals#custom-components) in their respective configs.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -546,5 +546,5 @@ export const useMyCustomContext = () => useContext(MyCustomContext)
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>React Context exists only within Client Components. This means they must include the `use client` directive at the top of their files and cannot contain server-only code. To use a Server Component here, simply _wrap_ your Client Component with it.
|
**Reminder:**React Context exists only within Client Components. This means they must include the `use client` directive at the top of their files and cannot contain server-only code. To use a Server Component here, simply _wrap_ your Client Component with it.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Here is an example of how you might target the Dashboard View and change the bac
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
If you are building [Custom Components](./components), it is best to import your own stylesheets directly into your components, rather than using the global stylesheet. You can continue to use the [CSS library](#css-library) as needed.
|
If you are building [Custom Components](./components), it is best to import your own stylesheets directly into your components, rather than using the global stylesheet. You can continue to use the [CSS library](#css-library) as needed.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ The following variables are defined and can be overridden:
|
|||||||
For an up-to-date, comprehensive list of all available variables, please refer to the [Source Code](https://github.com/payloadcms/payload/blob/main/packages/ui/src/scss).
|
For an up-to-date, comprehensive list of all available variables, please refer to the [Source Code](https://github.com/payloadcms/payload/blob/main/packages/ui/src/scss).
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Warning:</strong>
|
**Warning:**
|
||||||
If you're overriding colors or theme elevations, make sure to consider how [your changes will affect dark mode](#dark-mode).
|
If you're overriding colors or theme elevations, make sure to consider how [your changes will affect dark mode](#dark-mode).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ keywords:
|
|||||||
For example, your app might need to render a specific interface that Payload does not inherently support, such as a color picker. To do this, you could replace the default [Text Field](../fields/text) input with your own user-friendly component that formats the data into a valid color value.
|
For example, your app might need to render a specific interface that Payload does not inherently support, such as a color picker. To do this, you could replace the default [Text Field](../fields/text) input with your own user-friendly component that formats the data into a valid color value.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
Don't see a built-in field type that you need? Build it! Using a combination of [Field Validations](../fields/overview#validation)
|
Don't see a built-in field type that you need? Build it! Using a combination of [Field Validations](../fields/overview#validation)
|
||||||
and [Custom Components](./components), you can override the entirety of how a component functions within the [Admin Panel](./overview) to effectively create your own field type.
|
and [Custom Components](./components), you can override the entirety of how a component functions within the [Admin Panel](./overview) to effectively create your own field type.
|
||||||
</Banner>
|
</Banner>
|
||||||
@@ -87,7 +87,7 @@ export const MyCollectionConfig: SanitizedCollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
To replace the Field Description with a [Custom Component](./components), use the `admin.components.Description` property. [More details](#description).
|
To replace the Field Description with a [Custom Component](./components), use the `admin.components.Description` property. [More details](#description).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ All Description Functions receive the following arguments:
|
|||||||
| **`t`** | The `t` function used to internationalize the Admin Panel. [More details](../configuration/i18n) |
|
| **`t`** | The `t` function used to internationalize the Admin Panel. [More details](../configuration/i18n) |
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
If you need to subscribe to live updates within your form, use a Description Component instead. [More details](#description).
|
If you need to subscribe to live updates within your form, use a Description Component instead. [More details](#description).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ The following options are available:
|
|||||||
| **`views`** | Override or create new views within the Admin Panel. [More details](./views). |
|
| **`views`** | Override or create new views within the Admin Panel. [More details](./views). |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
For details on how to build Custom Components, see [Building Custom Components](./components#building-custom-components).
|
For details on how to build Custom Components, see [Building Custom Components](./components#building-custom-components).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -102,6 +102,6 @@ The preview function receives two arguments:
|
|||||||
| **`ctx`** | An object containing `locale` and `token` properties. The `token` is the currently logged-in user's JWT. |
|
| **`ctx`** | An object containing `locale` and `token` properties. The `token` is the currently logged-in user's JWT. |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
For fully working example of this, check of the official [Draft Preview Example](https://github.com/payloadcms/payload/tree/main/examples/draft-preview) in the [Examples Directory](https://github.com/payloadcms/payload/tree/main/examples).
|
For fully working example of this, check of the official [Draft Preview Example](https://github.com/payloadcms/payload/tree/main/examples/draft-preview) in the [Examples Directory](https://github.com/payloadcms/payload/tree/main/examples).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ keywords: admin, components, custom, documentation, Content Management System, c
|
|||||||
Payload provides a variety of powerful [React Hooks](https://react.dev/reference/react-dom/hooks) that can be used within your own [Custom Components](./components), such as [Custom Fields](./fields). With them, you can interface with Payload itself to build just about any type of complex customization you can think of.
|
Payload provides a variety of powerful [React Hooks](https://react.dev/reference/react-dom/hooks) that can be used within your own [Custom Components](./components), such as [Custom Fields](./fields). With them, you can interface with Payload itself to build just about any type of complex customization you can think of.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
All Custom Components are [React Server Components](https://react.dev/reference/rsc/server-components) by default. Hooks, on the other hand, are only available in client-side environments. To use hooks, [ensure your component is a client component](./components#client-components).
|
All Custom Components are [React Server Components](https://react.dev/reference/rsc/server-components) by default. Hooks, on the other hand, are only available in client-side environments. To use hooks, [ensure your component is a client component](./components#client-components).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ type FieldType<T> = {
|
|||||||
There are times when a custom field component needs to have access to data from other fields, and you have a few options to do so. The `useFormFields` hook is a powerful and highly performant way to retrieve a form's field state, as well as to retrieve the `dispatchFields` method, which can be helpful for setting other fields' form states from anywhere within a form.
|
There are times when a custom field component needs to have access to data from other fields, and you have a few options to do so. The `useFormFields` hook is a powerful and highly performant way to retrieve a form's field state, as well as to retrieve the `dispatchFields` method, which can be helpful for setting other fields' form states from anywhere within a form.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>This hook is great for retrieving only certain fields from form state</strong> because it
|
**This hook is great for retrieving only certain fields from form state** because it
|
||||||
ensures that it will only cause a rerender when the items that you ask for change.
|
ensures that it will only cause a rerender when the items that you ask for change.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -157,8 +157,8 @@ To see types for each action supported within the `dispatchFields` hook, check o
|
|||||||
The `useForm` hook can be used to interact with the form itself, and sends back many methods that can be used to reactively fetch form state without causing rerenders within your components each time a field is changed. This is useful if you have action-based callbacks that your components fire, and need to interact with form state _based on a user action_.
|
The `useForm` hook can be used to interact with the form itself, and sends back many methods that can be used to reactively fetch form state without causing rerenders within your components each time a field is changed. This is useful if you have action-based callbacks that your components fire, and need to interact with form state _based on a user action_.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Warning:</strong>
|
**Warning:**
|
||||||
<br />
|
|
||||||
This hook is optimized to avoid causing rerenders when fields change, and as such, its `fields`
|
This hook is optimized to avoid causing rerenders when fields change, and as such, its `fields`
|
||||||
property will be out of date. You should only leverage this hook if you need to perform actions
|
property will be out of date. You should only leverage this hook if you need to perform actions
|
||||||
against the form in response to your users' actions. Do not rely on its returned "fields" as being
|
against the form in response to your users' actions. Do not rely on its returned "fields" as being
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ When a user starts editing a document, Payload locks it for that user. If anothe
|
|||||||
|
|
||||||
The lock will automatically expire after a set period of inactivity, configurable using the `duration` property in the `lockDocuments` configuration, after which others can resume editing.
|
The lock will automatically expire after a set period of inactivity, configurable using the `duration` property in the `lockDocuments` configuration, after which others can resume editing.
|
||||||
|
|
||||||
<Banner type="info"> <strong>Note:</strong> If your application does not require document locking, you can disable this feature for any collection or global by setting the <code>lockDocuments</code> property to <code>false</code>. </Banner>
|
<Banner type="info"> **Note:** If your application does not require document locking, you can disable this feature for any collection or global by setting the `lockDocuments` property to `false`. </Banner>
|
||||||
|
|
||||||
### Config Options
|
### Config Options
|
||||||
|
|
||||||
The `lockDocuments` property exists on both the Collection Config and the Global Config. Document locking is enabled by default, but you can customize the lock duration or turn off the feature for any collection or global.
|
The `lockDocuments` property exists on both the Collection Config and the Global Config. Document locking is enabled by default, but you can customize the lock duration or turn off the feature for any collection or global.
|
||||||
|
|
||||||
Here’s an example configuration for document locking:
|
Here's an example configuration for document locking:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import type { CollectionConfig } from 'payload'
|
import type { CollectionConfig } from 'payload'
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ The following options are available for Root Metadata:
|
|||||||
| **`titleSuffix`** | `string` | A suffix to append to the end of the title of every page. Defaults to "- Payload". |
|
| **`titleSuffix`** | `string` | A suffix to append to the end of the title of every page. Defaults to "- Payload". |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
These are the _root-level_ options for the Admin Panel. You can also customize [Collection Metadata](./collections), [Global Metadata](./globals), and [Document Metadata](./documents) in their respective configs.
|
These are the _root-level_ options for the Admin Panel. You can also customize [Collection Metadata](./collections), [Global Metadata](./globals), and [Document Metadata](./documents) in their respective configs.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ As shown above, all Payload routes are nested within the `(payload)` route group
|
|||||||
The `admin` directory contains all the _pages_ related to the interface itself, whereas the `api` and `graphql` directories contains all the _routes_ related to the [REST API](../rest-api/overview) and [GraphQL API](../graphql/overview). All admin routes are [easily configurable](#customizing-routes) to meet your application's exact requirements.
|
The `admin` directory contains all the _pages_ related to the interface itself, whereas the `api` and `graphql` directories contains all the _routes_ related to the [REST API](../rest-api/overview) and [GraphQL API](../graphql/overview). All admin routes are [easily configurable](#customizing-routes) to meet your application's exact requirements.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
If you don't use the [REST API](../rest/overview) or [GraphQL API](../graphql/overview), you can delete the [Next.js files corresponding to those routes](../admin/overview#project-structure), however, the overhead of this API is completely constrained to these endpoints, and will not slow down or affect Payload outside of the endpoints.
|
If you don't use the [REST API](../rest/overview) or [GraphQL API](../graphql/overview), you can delete the [Next.js files corresponding to those routes](../admin/overview#project-structure), however, the overhead of this API is completely constrained to these endpoints, and will not slow down or affect Payload outside of the endpoints.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ The following options are available:
|
|||||||
| **`user`** | The `slug` of the Collection that you want to allow to login to the Admin Panel. [More details](#the-admin-user-collection). |
|
| **`user`** | The `slug` of the Collection that you want to allow to login to the Admin Panel. [More details](#the-admin-user-collection). |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
These are the _root-level_ options for the Admin Panel. You can also customize [Collection Admin Options](./collections) and [Global Admin Options](./globals) through their respective `admin` keys.
|
These are the _root-level_ options for the Admin Panel. You can also customize [Collection Admin Options](./collections) and [Global Admin Options](./globals) through their respective `admin` keys.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -123,8 +123,8 @@ const config = buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
<br />
|
|
||||||
The Admin Panel can only be used by a single auth-enabled Collection. To enable authentication for a Collection, simply set `auth: true` in the Collection's configuration. See [Authentication](../authentication/overview) for more information.
|
The Admin Panel can only be used by a single auth-enabled Collection. To enable authentication for a Collection, simply set `auth: true` in the Collection's configuration. See [Authentication](../authentication/overview) for more information.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ The following options are available:
|
|||||||
| `graphQLPlayground` | `/graphql-playground` | The GraphQL Playground. |
|
| `graphQLPlayground` | `/graphql-playground` | The GraphQL Playground. |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
You can easily add _new_ routes to the Admin Panel through [Custom Endpoints](../rest-api/overview#custom-endpoints) and [Custom Views](./views).
|
You can easily add _new_ routes to the Admin Panel through [Custom Endpoints](../rest-api/overview#custom-endpoints) and [Custom Views](./views).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ app/
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
If you set Root-level Routes _before_ auto-generating the Admin Panel via `create-payload-app`, your [Project Structure](#project-structure) will already be set up correctly.
|
If you set Root-level Routes _before_ auto-generating the Admin Panel via `create-payload-app`, your [Project Structure](#project-structure) will already be set up correctly.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ The following options are available:
|
|||||||
| `unauthorized` | `/unauthorized` | The unauthorized page. |
|
| `unauthorized` | `/unauthorized` | The unauthorized page. |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
You can also swap out entire _views_ out for your own, using the `admin.views` property of the Payload Config. See [Custom Views](./views) for more information.
|
You can also swap out entire _views_ out for your own, using the `admin.views` property of the Payload Config. See [Custom Views](./views) for more information.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ Out of the box, Payload handles the persistence of your users' preferences in a
|
|||||||
1. The last-known state of the `Nav` component, etc.
|
1. The last-known state of the `Nav` component, etc.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
<br />
|
|
||||||
All preferences are stored on an individual user basis. Payload automatically recognizes the user
|
All preferences are stored on an individual user basis. Payload automatically recognizes the user
|
||||||
that is reading or setting a preference via all provided authentication methods.
|
that is reading or setting a preference via all provided authentication methods.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export const MyCustomView: React.FC<AdminViewProps> = ({
|
|||||||
>
|
>
|
||||||
<Gutter>
|
<Gutter>
|
||||||
<h1>Custom Default Root View</h1>
|
<h1>Custom Default Root View</h1>
|
||||||
<br />
|
|
||||||
<p>This view uses the Default Template.</p>
|
<p>This view uses the Default Template.</p>
|
||||||
</Gutter>
|
</Gutter>
|
||||||
</DefaultTemplate>
|
</DefaultTemplate>
|
||||||
@@ -125,8 +125,8 @@ const config = buildConfig({
|
|||||||
The above example shows how to add a new [Root View](#root-views), but the pattern is the same for [Collection Views](#collection-views), [Global Views](#global-views), and [Document Views](#document-views). For help on how to build your own Custom Views, see [Building Custom Views](#building-custom-views).
|
The above example shows how to add a new [Root View](#root-views), but the pattern is the same for [Collection Views](#collection-views), [Global Views](#global-views), and [Document Views](#document-views). For help on how to build your own Custom Views, see [Building Custom Views](#building-custom-views).
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
Routes are cascading, so unless explicitly given the `exact` property, they will
|
Routes are cascading, so unless explicitly given the `exact` property, they will
|
||||||
match on URLs that simply _start_ with the route's path. This is helpful when creating catch-all
|
match on URLs that simply _start_ with the route's path. This is helpful when creating catch-all
|
||||||
routes in your application. Alternatively, define your nested route _before_ your parent
|
routes in your application. Alternatively, define your nested route _before_ your parent
|
||||||
@@ -134,8 +134,8 @@ The above example shows how to add a new [Root View](#root-views), but the patte
|
|||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Custom views are public</strong>
|
**Custom views are public**
|
||||||
<br />
|
|
||||||
Custom views are public by default. If your view requires a user to be logged in or to have certain access rights, you should handle that within your view component yourself.
|
Custom views are public by default. If your view requires a user to be logged in or to have certain access rights, you should handle that within your view component yourself.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ export const MyCollectionConfig: SanitizedCollectionConfig = {
|
|||||||
_For details on how to build Custom Views, including all available props, see [Building Custom Views](#building-custom-views)._
|
_For details on how to build Custom Views, including all available props, see [Building Custom Views](#building-custom-views)._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
The `root` property will replace the _entire_ Edit View, including the title, tabs, etc., _as well as all nested [Document Views](#document-views)_, such as the API, Live Preview, and Version views. To replace only the Edit View precisely, use the `edit.default` key instead.
|
The `root` property will replace the _entire_ Edit View, including the title, tabs, etc., _as well as all nested [Document Views](#document-views)_, such as the API, Live Preview, and Version views. To replace only the Edit View precisely, use the `edit.default` key instead.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ The following options are available:
|
|||||||
| **`list`** | The List View is used to show a list of documents for any given Collection. |
|
| **`list`** | The List View is used to show a list of documents for any given Collection. |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
You can also add _new_ Collection Views to the config by adding a new key to the `views` object with at least a `path` and `Component` property. See [Adding New Views](#adding-new-views) for more information.
|
You can also add _new_ Collection Views to the config by adding a new key to the `views` object with at least a `path` and `Component` property. See [Adding New Views](#adding-new-views) for more information.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ export const MyGlobalConfig: SanitizedGlobalConfig = {
|
|||||||
_For details on how to build Custom Views, including all available props, see [Building Custom Views](#building-custom-views)._
|
_For details on how to build Custom Views, including all available props, see [Building Custom Views](#building-custom-views)._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
The `root` property will replace the _entire_ Edit View, including the title, tabs, etc., _as well as all nested [Document Views](#document-views)_, such as the API, Live Preview, and Version views. To replace only the Edit View precisely, use the `edit.default` key instead.
|
The `root` property will replace the _entire_ Edit View, including the title, tabs, etc., _as well as all nested [Document Views](#document-views)_, such as the API, Live Preview, and Version views. To replace only the Edit View precisely, use the `edit.default` key instead.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ The following options are available:
|
|||||||
| **`edit`** | The Edit View is used to edit a single document for any given Global. [More details](#document-views). |
|
| **`edit`** | The Edit View is used to edit a single document for any given Global. [More details](#document-views). |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
You can also add _new_ Global Views to the config by adding a new key to the `views` object with at least a `path` and `Component` property. See [Adding New Views](#adding-new-views) for more information.
|
You can also add _new_ Global Views to the config by adding a new key to the `views` object with at least a `path` and `Component` property. See [Adding New Views](#adding-new-views) for more information.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ export const MyCollectionOrGlobalConfig: SanitizedCollectionConfig = {
|
|||||||
_For details on how to build Custom Views, including all available props, see [Building Custom Views](#building-custom-views)._
|
_For details on how to build Custom Views, including all available props, see [Building Custom Views](#building-custom-views)._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
If you need to replace the _entire_ Edit View, including _all_ nested Document Views, use the `root` key. See [Custom Collection Views](#collection-views) or [Custom Global Views](#global-views) for more information.
|
If you need to replace the _entire_ Edit View, including _all_ nested Document Views, use the `root` key. See [Custom Collection Views](#collection-views) or [Custom Global Views](#global-views) for more information.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ export const MyCollection: SanitizedCollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
This applies to _both_ Collections _and_ Globals.
|
This applies to _both_ Collections _and_ Globals.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -364,12 +364,12 @@ Your Custom Views will be provided with the following props:
|
|||||||
| **`doc`** | The document being edited. Only available in Document Views. [More details](#document-views). |
|
| **`doc`** | The document being edited. Only available in Document Views. [More details](#document-views). |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
All [Custom Server Components](./components) receive `payload` and `i18n` by default. See [Building Custom Components](./components#building-custom-components) for more details.
|
All [Custom Server Components](./components) receive `payload` and `i18n` by default. See [Building Custom Components](./components#building-custom-components) for more details.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
It's up to you to secure your custom views. If your view requires a user to be logged in or to
|
It's up to you to secure your custom views. If your view requires a user to be logged in or to
|
||||||
have certain access rights, you should handle that within your view component yourself.
|
have certain access rights, you should handle that within your view component yourself.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ For example, if you have a third-party service or external app that needs to be
|
|||||||
1. Generate a non-expiring API key for that user to request with.
|
1. Generate a non-expiring API key for that user to request with.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br/>
|
<br/>
|
||||||
This is particularly useful as you can create a "user" that reflects an integration with a specific external service and assign a "role" or specific access only needed by that service/integration.
|
This is particularly useful as you can create a "user" that reflects an integration with a specific external service and assign a "role" or specific access only needed by that service/integration.
|
||||||
</Banner>
|
</Banner>
|
||||||
@@ -39,9 +39,9 @@ User API keys are encrypted within the database, meaning that if your database i
|
|||||||
your API keys will not be.
|
your API keys will not be.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
If you change your `PAYLOAD_SECRET`, you will need to regenerate your API keys.
|
If you change your `PAYLOAD_SECRET`, you will need to regenerate your API keys.
|
||||||
<br />
|
|
||||||
The secret key is used to encrypt the API keys, so if you change the secret, existing API keys will
|
The secret key is used to encrypt the API keys, so if you change the secret, existing API keys will
|
||||||
no longer be valid.
|
no longer be valid.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ keywords: authentication, config, configuration, documentation, Content Manageme
|
|||||||
Payload offers the ability to [Authenticate](./overview) via HTTP-only cookies. These can be read from the responses of `login`, `logout`, `refresh`, and `me` auth operations.
|
Payload offers the ability to [Authenticate](./overview) via HTTP-only cookies. These can be read from the responses of `login`, `logout`, `refresh`, and `me` auth operations.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
You can access the logged-in user from within [Access Control](../access-control/overview) and [Hooks](../hooks/overview) through the `req.user` argument. [More details](./token-data).
|
You can access the logged-in user from within [Access Control](../access-control/overview) and [Hooks](../hooks/overview) through the `req.user` argument. [More details](./token-data).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ const pages = await response.json()
|
|||||||
For more about including cookies in requests from your app to your Payload API, [read the MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Sending_a_request_with_credentials_included).
|
For more about including cookies in requests from your app to your Payload API, [read the MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Sending_a_request_with_credentials_included).
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
To make sure you have a Payload cookie set properly in your browser after logging in, you can use
|
To make sure you have a Payload cookie set properly in your browser after logging in, you can use
|
||||||
the browsers Developer Tools > Application > Cookies > [your-domain-here]. The Developer tools
|
the browsers Developer Tools > Application > Cookies > [your-domain-here]. The Developer tools
|
||||||
will still show HTTP-only cookies.
|
will still show HTTP-only cookies.
|
||||||
@@ -44,7 +44,7 @@ For more about including cookies in requests from your app to your Payload API,
|
|||||||
|
|
||||||
CSRF (cross-site request forgery) attacks are common and dangerous. By using an HTTP-only cookie, Payload removes many XSS vulnerabilities, however, CSRF attacks can still be possible.
|
CSRF (cross-site request forgery) attacks are common and dangerous. By using an HTTP-only cookie, Payload removes many XSS vulnerabilities, however, CSRF attacks can still be possible.
|
||||||
|
|
||||||
For example, let's say you have a popular app `https://payload-finances.com` that allows users to manage finances, send and receive money. As Payload is using HTTP-only cookies, that means that browsers automatically will include cookies when sending requests to your domain - <strong>no matter what page created the request</strong>.
|
For example, let's say you have a popular app `https://payload-finances.com` that allows users to manage finances, send and receive money. As Payload is using HTTP-only cookies, that means that browsers automatically will include cookies when sending requests to your domain - **no matter what page created the request**.
|
||||||
|
|
||||||
So, if a user of `https://payload-finances.com` is logged in and is browsing around on the internet, they might stumble onto a page with malicious intent. Let's look at an example:
|
So, if a user of `https://payload-finances.com` is logged in and is browsing around on the internet, they might stumble onto a page with malicious intent. Let's look at an example:
|
||||||
|
|
||||||
@@ -126,6 +126,6 @@ If you're configuring [cors](../production/preventing-abuse#cross-origin-resourc
|
|||||||
|
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Good to know:</strong>
|
**Good to know:**
|
||||||
Setting up <code>secure: true</code> will not work if you're developing on <code>http://localhost</code> or any non-https domain. For local development you should conditionally set this to <code>false</code> based on the environment.
|
Setting up `secure: true` will not work if you're developing on `http://localhost` or any non-https domain. For local development you should conditionally set this to `false` based on the environment.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const Customers: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
Verification emails are fully customizable. [More details](#generateEmailHTML).
|
Verification emails are fully customizable. [More details](#generateEmailHTML).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ export const Customers: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
If you specify a different URL to send your users to for email verification, such as a page on the
|
If you specify a different URL to send your users to for email verification, such as a page on the
|
||||||
frontend of your app or similar, you need to handle making the call to the Payload REST or GraphQL
|
frontend of your app or similar, you need to handle making the call to the Payload REST or GraphQL
|
||||||
verification operation yourself on your frontend, using the token that was provided for you.
|
verification operation yourself on your frontend, using the token that was provided for you.
|
||||||
@@ -152,7 +152,7 @@ export const Customers: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
If you specify a different URL to send your users to for resetting their password, such as a page
|
If you specify a different URL to send your users to for resetting their password, such as a page
|
||||||
on the frontend of your app or similar, you need to handle making the call to the Payload REST or
|
on the frontend of your app or similar, you need to handle making the call to the Payload REST or
|
||||||
GraphQL reset-password operation yourself on your frontend, using the token that was provided for
|
GraphQL reset-password operation yourself on your frontend, using the token that was provided for
|
||||||
@@ -160,7 +160,7 @@ export const Customers: CollectionConfig = {
|
|||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
HTML templating can be used to create custom email templates, inline CSS automatically, and more.
|
HTML templating can be used to create custom email templates, inline CSS automatically, and more.
|
||||||
You can make a reusable function that standardizes all email sent from Payload, which makes
|
You can make a reusable function that standardizes all email sent from Payload, which makes
|
||||||
sending custom emails more DRY. Payload doesn't ship with an HTML templating engine, so you are
|
sending custom emails more DRY. Payload doesn't ship with an HTML templating engine, so you are
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ keywords: authentication, config, configuration, documentation, Content Manageme
|
|||||||
Payload offers the ability to [Authenticate](./overview) via JSON Web Tokens (JWT). These can be read from the responses of `login`, `logout`, `refresh`, and `me` auth operations.
|
Payload offers the ability to [Authenticate](./overview) via JSON Web Tokens (JWT). These can be read from the responses of `login`, `logout`, `refresh`, and `me` auth operations.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
You can access the logged-in user from within [Access Control](../access-control/overview) and [Hooks](../hooks/overview) through the `req.user` argument. [More details](./token-data).
|
You can access the logged-in user from within [Access Control](../access-control/overview) and [Hooks](../hooks/overview) through the `req.user` argument. [More details](./token-data).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -345,8 +345,8 @@ const token = await payload.forgotPassword({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br />
|
|
||||||
You can stop the reset-password email from being sent via using the local API. This is helpful if
|
You can stop the reset-password email from being sent via using the local API. This is helpful if
|
||||||
you need to create user accounts programmatically, but not set their password for them. This
|
you need to create user accounts programmatically, but not set their password for them. This
|
||||||
effectively generates a reset password token which you can then use to send to a page you create,
|
effectively generates a reset password token which you can then use to send to a page you create,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ _Admin Panel screenshot depicting an Admins Collection with Auth enabled_
|
|||||||
Any [Collection](../configuration/collections) can opt-in to supporting Authentication. Once enabled, each Document that is created within the Collection can be thought of as a "user". This enables a complete authentication workflow on your Collection, such as logging in and out, resetting their password, and more.
|
Any [Collection](../configuration/collections) can opt-in to supporting Authentication. Once enabled, each Document that is created within the Collection can be thought of as a "user". This enables a complete authentication workflow on your Collection, such as logging in and out, resetting their password, and more.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
By default, Payload provides an auth-enabled `User` Collection which is used to access the Admin Panel. [More details](../admin/overview#the-admin-user-collection).
|
By default, Payload provides an auth-enabled `User` Collection which is used to access the Admin Panel. [More details](../admin/overview#the-admin-user-collection).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ export const Admins: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
For default auth behavior, set `auth: true`. This is a good starting point for most applications.
|
For default auth behavior, set `auth: true`. This is a good starting point for most applications.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
Auth-enabled Collections with be automatically injected with the `hash`, `salt`, and `email` fields. [More details](../fields/overview#field-names).
|
Auth-enabled Collections with be automatically injected with the `hash`, `salt`, and `email` fields. [More details](../fields/overview#field-names).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Warning:</strong>
|
**Warning:**
|
||||||
The recommended way to use this feature is behind an [Environment Variable](../configuration/environment-vars). This will ensure it is _disabled_ in production.
|
The recommended way to use this feature is behind an [Environment Variable](../configuration/environment-vars). This will ensure it is _disabled_ in production.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ Each of these strategies can work together or independently. You can also create
|
|||||||
|
|
||||||
### HTTP-Only Cookies
|
### HTTP-Only Cookies
|
||||||
|
|
||||||
[HTTP-only cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) are a highly secure method of storing identifiable data on a user's device so that Payload can automatically recognize a returning user until their cookie expires. They are totally protected from common XSS attacks and <strong>cannot be read by JavaScript in the browser</strong>, unlike JWT's. [More details](./cookies).
|
[HTTP-only cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) are a highly secure method of storing identifiable data on a user's device so that Payload can automatically recognize a returning user until their cookie expires. They are totally protected from common XSS attacks and **cannot be read by JavaScript in the browser**, unlike JWT's. [More details](./cookies).
|
||||||
|
|
||||||
### JSON Web Tokens
|
### JSON Web Tokens
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export const Users: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br/>
|
<br/>
|
||||||
If you wish to use a different key other than the field `name`, you can define `saveToJWT` as a string.
|
If you wish to use a different key other than the field `name`, you can define `saveToJWT` as a string.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ Any of the features in Payload Cloud that require environment variables will aut
|
|||||||
Payment methods can be set per project and can be updated any time. You can use team’s default payment method, or add a new one. Modify your payment methods in your Project settings / Team settings.
|
Payment methods can be set per project and can be updated any time. You can use team’s default payment method, or add a new one. Modify your payment methods in your Project settings / Team settings.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong> All Payload Cloud teams that deploy a project require a card on file. This
|
**Note:** All Payload Cloud teams that deploy a project require a card on file. This
|
||||||
helps us prevent fraud and abuse on our platform. If you select a plan with a free trial, you will
|
helps us prevent fraud and abuse on our platform. If you select a plan with a free trial, you will
|
||||||
not be charged until your trial period is over. We’ll remind you 7 days before your trial ends and
|
not be charged until your trial period is over. We’ll remind you 7 days before your trial ends and
|
||||||
you can cancel anytime.
|
you can cancel anytime.
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Next, select your `GitHub Scope`. If you belong to multiple organizations, they
|
|||||||
After selecting your scope, create a unique `repository name` and select whether you want your repository to be public or private on GitHub.
|
After selecting your scope, create a unique `repository name` and select whether you want your repository to be public or private on GitHub.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong> Public repositories can be accessed by anyone online, while private
|
**Note:** Public repositories can be accessed by anyone online, while private
|
||||||
repositories grant access only to you and anyone you explicitly authorize.
|
repositories grant access only to you and anyone you explicitly authorize.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ Payload Cloud works for any Node.js + MongoDB app. From the New Project page, se
|
|||||||
_Creating a new project from an existing repository._
|
_Creating a new project from an existing repository._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong> In order to make use of the features of Payload Cloud in your own codebase,
|
**Note:** In order to make use of the features of Payload Cloud in your own codebase,
|
||||||
you will need to add the [Cloud Plugin](https://github.com/payloadcms/payload/tree/main/packages/payload-cloud) to your
|
you will need to add the [Cloud Plugin](https://github.com/payloadcms/payload/tree/main/packages/payload-cloud) to your
|
||||||
Payload app.
|
Payload app.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
If your Collection is only ever meant to contain a single Document, consider using a [Global](./globals) instead.
|
If your Collection is only ever meant to contain a single Document, consider using a [Global](./globals) instead.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export const Posts: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
For more complex examples, see the [Templates](https://github.com/payloadcms/payload/tree/main/templates) and [Examples](https://github.com/payloadcms/payload/tree/main/examples) directories in the Payload repository.
|
For more complex examples, see the [Templates](https://github.com/payloadcms/payload/tree/main/templates) and [Examples](https://github.com/payloadcms/payload/tree/main/examples) directories in the Payload repository.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ For security and safety reasons, the [Admin Panel](../admin/overview) does **not
|
|||||||
If you are building a [Custom Component](../admin/components) and need to access Environment Variables from the client-side, you can do so by prefixing them with `NEXT_PUBLIC_`.
|
If you are building a [Custom Component](../admin/components) and need to access Environment Variables from the client-side, you can do so by prefixing them with `NEXT_PUBLIC_`.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Be careful about what variables you provide to your client-side code. Analyze every single one to make sure that you're not accidentally leaking sensitive information. Only ever include keys that are safe for the public to read in plain text.
|
Be careful about what variables you provide to your client-side code. Analyze every single one to make sure that you're not accidentally leaking sensitive information. Only ever include keys that are safe for the public to read in plain text.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
Be sure that `dotenv` can find your `.env` file. By default, it will look for a file named `.env` in the root of your project. If you need to specify a different file, pass the path into the config options.
|
Be sure that `dotenv` can find your `.env` file. By default, it will look for a file named `.env` in the root of your project. If you need to specify a different file, pass the path into the config options.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
If you have more than one Global that share the same structure, consider using a [Collection](../configuration/collections) instead.
|
If you have more than one Global that share the same structure, consider using a [Collection](../configuration/collections) instead.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ export const Nav: GlobalConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
For more complex examples, see the [Templates](https://github.com/payloadcms/payload/tree/main/templates) and [Examples](https://github.com/payloadcms/payload/tree/main/examples) directories in the Payload repository.
|
For more complex examples, see the [Templates](https://github.com/payloadcms/payload/tree/main/templates) and [Examples](https://github.com/payloadcms/payload/tree/main/examples) directories in the Payload repository.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
If there is a language that Payload does not yet support, we accept [code contributions](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md).
|
If there is a language that Payload does not yet support, we accept [code contributions](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
It's best to only support the languages that you need so that the bundled JavaScript is kept to a minimum for your project.
|
It's best to only support the languages that you need so that the bundled JavaScript is kept to a minimum for your project.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
Localization works very well alongside [I18n](/docs/configuration/i18n).
|
Localization works very well alongside [I18n](/docs/configuration/i18n).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ With the above configuration, the `title` field will now be saved in the databas
|
|||||||
All field types with a `name` property support the `localized` property—even the more complex field types like `array`s and `block`s.
|
All field types with a `name` property support the `localized` property—even the more complex field types like `array`s and `block`s.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
Enabling Localization for field types that support nested fields will automatically create
|
Enabling Localization for field types that support nested fields will automatically create
|
||||||
localized "sets" of all fields contained within the field. For example, if you have a page layout
|
localized "sets" of all fields contained within the field. For example, if you have a page layout
|
||||||
using a blocks field type, you have the choice of either localizing the full layout, by enabling
|
using a blocks field type, you have the choice of either localizing the full layout, by enabling
|
||||||
@@ -129,7 +129,7 @@ All field types with a `name` property support the `localized` property—even t
|
|||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
When converting an existing field to or from `localized: true` the data structure in the document
|
When converting an existing field to or from `localized: true` the data structure in the document
|
||||||
will change for this field and so existing data for this field will be lost. Before changing the
|
will change for this field and so existing data for this field will be lost. Before changing the
|
||||||
Localization setting on fields with existing data, you may need to consider a field migration
|
Localization setting on fields with existing data, you may need to consider a field migration
|
||||||
@@ -205,8 +205,8 @@ const posts = await payload.find({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
The REST and Local APIs can return all Localization data in one request by passing 'all' or '*' as
|
The REST and Local APIs can return all Localization data in one request by passing 'all' or '*' as
|
||||||
the <strong>locale</strong> parameter. The response will be structured so that field values come
|
the **locale** parameter. The response will be structured so that field values come
|
||||||
back as the full objects keyed for each locale instead of the single, translated value.
|
back as the full objects keyed for each locale instead of the single, translated value.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default buildConfig({
|
|||||||
The Payload Config is strongly typed and ties directly into Payload's TypeScript codebase. This means your IDE (such as VSCode) will provide helpful information like type-ahead suggestions while you write your config.
|
The Payload Config is strongly typed and ties directly into Payload's TypeScript codebase. This means your IDE (such as VSCode) will provide helpful information like type-ahead suggestions while you write your config.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
The location of your Payload Config can be customized. [More details](#customizing--automating-config-location-detection).
|
The location of your Payload Config can be customized. [More details](#customizing--automating-config-location-detection).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
For more complex examples, see the [Templates](https://github.com/payloadcms/payload/tree/main/templates) and [Examples](https://github.com/payloadcms/payload/tree/main/examples) directories in the Payload repository.
|
For more complex examples, see the [Templates](https://github.com/payloadcms/payload/tree/main/templates) and [Examples](https://github.com/payloadcms/payload/tree/main/examples) directories in the Payload repository.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ The following options are available:
|
|||||||
_\* An asterisk denotes that a property is required._
|
_\* An asterisk denotes that a property is required._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
Some properties are removed from the client-side bundle. [More details](../admin/components#accessing-the-payload-config).
|
Some properties are removed from the client-side bundle. [More details](../admin/components#accessing-the-payload-config).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ For Payload command-line scripts, we need to be able to locate your Payload Conf
|
|||||||
_\* Config location detection is different between development and production environments. See below for more details._
|
_\* Config location detection is different between development and production environments. See below for more details._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Ensure your `tsconfig.json` is properly configured for Payload to auto-detect your config location. If if does not exist, or does not specify the proper `compilerOptions`, Payload will default to the current working directory.
|
Ensure your `tsconfig.json` is properly configured for Payload to auto-detect your config location. If if does not exist, or does not specify the proper `compilerOptions`, Payload will default to the current working directory.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ To use a custom config location, set the `PAYLOAD_CONFIG_PATH` environment varia
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
`PAYLOAD_CONFIG_PATH` can be either an absolute path, or path relative to your current working directory.
|
`PAYLOAD_CONFIG_PATH` can be either an absolute path, or path relative to your current working directory.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
The Database Adapter is an external dependency and must be installed in your project separately from Payload. You can find the installation instructions for each Database Adapter in their respective documentation.
|
The Database Adapter is an external dependency and must be installed in your project separately from Payload. You can find the installation instructions for each Database Adapter in their respective documentation.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export default buildConfig({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
If when using `vercelPostgresAdapter` your `process.env.POSTGRES_URL` or `pool.connectionString` points to a local database (e.g hostname has `localhost` or `127.0.0.1`) we use the `pg` module for pooling instead of `@vercel/postgres`. This is because `@vercel/postgres` doesn't work with local databases, if you want to disable that behavior, you can pass `forceUseVercelPostgres: true` to adapter's 'args and follow [Vercel guide](https://vercel.com/docs/storage/vercel-postgres/local-development#option-2:-local-postgres-instance-with-docker) for a Docker Neon DB setup.
|
If when using `vercelPostgresAdapter` your `process.env.POSTGRES_URL` or `pool.connectionString` points to a local database (e.g hostname has `localhost` or `127.0.0.1`) we use the `pg` module for pooling instead of `@vercel/postgres`. This is because `@vercel/postgres` doesn't work with local databases, if you want to disable that behavior, you can pass `forceUseVercelPostgres: true` to adapter's 'args and follow [Vercel guide](https://vercel.com/docs/storage/vercel-postgres/local-development#option-2:-local-postgres-instance-with-docker) for a Docker Neon DB setup.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ Database transactions allow your application to make a series of database change
|
|||||||
By default, Payload will use transactions for all data changing operations, as long as it is supported by the configured database. Database changes are contained within all Payload operations and any errors thrown will result in all changes being rolled back without being committed. When transactions are not supported by the database, Payload will continue to operate as expected without them.
|
By default, Payload will use transactions for all data changing operations, as long as it is supported by the configured database. Database changes are contained within all Payload operations and any errors thrown will result in all changes being rolled back without being committed. When transactions are not supported by the database, Payload will continue to operate as expected without them.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
MongoDB requires a connection to a replicaset in order to make use of transactions.
|
MongoDB requires a connection to a replicaset in order to make use of transactions.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
Transactions in SQLite are disabled by default. You need to pass `transactionOptions: {}` to enable them.
|
Transactions in SQLite are disabled by default. You need to pass `transactionOptions: {}` to enable them.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ desc: The Blocks Field is a great layout build and can be used to construct any
|
|||||||
keywords: blocks, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, nextjs
|
keywords: blocks, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, nextjs
|
||||||
---
|
---
|
||||||
|
|
||||||
The Blocks Field is <strong>incredibly powerful</strong>, storing an array of objects based on the fields that your define, where each item in the array is a "block" with its own unique schema.
|
The Blocks Field is **ncredibly powerful** storing an array of objects based on the fields that your define, where each item in the array is a "block" with its own unique schema.
|
||||||
|
|
||||||
Blocks are a great way to create a flexible content model that can be used to build a wide variety of content types, including:
|
Blocks are a great way to create a flexible content model that can be used to build a wide variety of content types, including:
|
||||||
|
|
||||||
@@ -96,28 +96,28 @@ This is super handy if you'd like to present your editors with a very deliberate
|
|||||||
For example, if you have a `gallery` block, you might want to actually render the gallery of images directly in your Lexical block. With the `admin.components.Block` property, you can do exactly that!
|
For example, if you have a `gallery` block, you might want to actually render the gallery of images directly in your Lexical block. With the `admin.components.Block` property, you can do exactly that!
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong><br/>
|
**Tip:**<br/>
|
||||||
If you customize the way your block is rendered in Lexical, you can import utility components to easily edit / remove your block - so that you don't have to build all of this yourself.
|
If you customize the way your block is rendered in Lexical, you can import utility components to easily edit / remove your block - so that you don't have to build all of this yourself.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
To import these utility components for one of your custom blocks, you can import the following:
|
To import these utility components for one of your custom blocks, you can import the following:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import {
|
import {
|
||||||
// Edit block buttons (choose the one that corresponds to your usage)
|
// Edit block buttons (choose the one that corresponds to your usage)
|
||||||
// When clicked, this will open a drawer with your block's fields
|
// When clicked, this will open a drawer with your block's fields
|
||||||
// so your editors can edit them
|
// so your editors can edit them
|
||||||
InlineBlockEditButton,
|
InlineBlockEditButton,
|
||||||
BlockEditButton,
|
BlockEditButton,
|
||||||
|
|
||||||
// Buttons that will remove this block from Lexical
|
// Buttons that will remove this block from Lexical
|
||||||
// (choose the one that corresponds to your usage)
|
// (choose the one that corresponds to your usage)
|
||||||
InlineBlockRemoveButton,
|
InlineBlockRemoveButton,
|
||||||
BlockRemoveButton,
|
BlockRemoveButton,
|
||||||
|
|
||||||
// The label that should be rendered for an inline block
|
// The label that should be rendered for an inline block
|
||||||
InlineBlockLabel,
|
InlineBlockLabel,
|
||||||
|
|
||||||
// The default "container" that is rendered for an inline block
|
// The default "container" that is rendered for an inline block
|
||||||
// if you want to re-use it
|
// if you want to re-use it
|
||||||
InlineBlockContainer,
|
InlineBlockContainer,
|
||||||
@@ -125,7 +125,7 @@ import {
|
|||||||
// The default "collapsible" UI that is rendered for a regular block
|
// The default "collapsible" UI that is rendered for a regular block
|
||||||
// if you want to re-use it
|
// if you want to re-use it
|
||||||
BlockCollapsible,
|
BlockCollapsible,
|
||||||
|
|
||||||
} from '@payloadcms/richtext-lexical/client'
|
} from '@payloadcms/richtext-lexical/client'
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -134,8 +134,8 @@ import {
|
|||||||
Blocks are defined as separate configs of their own.
|
Blocks are defined as separate configs of their own.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br />
|
|
||||||
Best practice is to define each block config in its own file, and then import them into your
|
Best practice is to define each block config in its own file, and then import them into your
|
||||||
Blocks field as necessary. This way each block config can be easily shared between fields. For
|
Blocks field as necessary. This way each block config can be easily shared between fields. For
|
||||||
instance, using the "layout builder" example, you might want to feature a few of the same blocks
|
instance, using the "layout builder" example, you might want to feature a few of the same blocks
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ are related to the Category are populated for you. This is extremely powerful an
|
|||||||
of relationship types in an easy manner.
|
of relationship types in an easy manner.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
The Join field is extremely performant and does not add additional query overhead to your API responses until you add depth of 1 or above. It works in all database adapters. In MongoDB, we use <strong>aggregations</strong> to automatically join in related documents, and in relational databases, we use joins.
|
The Join field is extremely performant and does not add additional query overhead to your API responses until you add depth of 1 or above. It works in all database adapters. In MongoDB, we use **aggregations** to automatically join in related documents, and in relational databases, we use joins.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
### Schema advice
|
### Schema advice
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const Page: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
Each field is an object with at least the `type` property. This matches the field to its corresponding Field Type. [More details](#field-options).
|
Each field is an object with at least the `type` property. This matches the field to its corresponding Field Type. [More details](#field-options).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ Here are the available Presentational Fields:
|
|||||||
- [UI](/docs/fields/ui) - blank field for custom UI components
|
- [UI](/docs/fields/ui) - blank field for custom UI components
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
Don't see a Field Type that fits your needs? You can build your own using a [Custom Field Component](../admin/fields#field).
|
Don't see a Field Type that fits your needs? You can build your own using a [Custom Field Component](../admin/fields#field).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ export const myField: Field = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
You can use async `defaultValue` functions to fill fields with data from API requests or Local API using `req.payload`.
|
You can use async `defaultValue` functions to fill fields with data from API requests or Local API using `req.payload`.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -378,7 +378,7 @@ export const MyCollection: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
The Custom ID Fields can only be of type [`Number`](./number) or [`Text`](./text).
|
The Custom ID Fields can only be of type [`Number`](./number) or [`Text`](./text).
|
||||||
|
|
||||||
Custom ID fields with type `text` must not contain `/` or `.` characters.
|
Custom ID fields with type `text` must not contain `/` or `.` characters.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const MyPointField: Field = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
The Point Field currently is not supported in SQLite.
|
The Point Field currently is not supported in SQLite.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ export const MyRadioField: Field = {
|
|||||||
_\* An asterisk denotes that a property is required._
|
_\* An asterisk denotes that a property is required._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
<br />
|
|
||||||
Option values should be strings that do not contain hyphens or special characters due to GraphQL
|
Option values should be strings that do not contain hyphens or special characters due to GraphQL
|
||||||
enumeration naming constraints. Underscores are allowed. If you determine you need your option
|
enumeration naming constraints. Underscores are allowed. If you determine you need your option
|
||||||
values to be non-strings or contain special characters, they will be formatted accordingly before
|
values to be non-strings or contain special characters, they will be formatted accordingly before
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const MyRelationshipField: Field = {
|
|||||||
_\* An asterisk denotes that a property is required._
|
_\* An asterisk denotes that a property is required._
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
The [Depth](../queries/depth) parameter can be used to automatically populate related documents that are returned by the API.
|
The [Depth](../queries/depth) parameter can be used to automatically populate related documents that are returned by the API.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -191,12 +191,12 @@ export const ExampleCollection: CollectionConfig = {
|
|||||||
You can learn more about writing queries [here](/docs/queries/overview).
|
You can learn more about writing queries [here](/docs/queries/overview).
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
When a relationship field has both <strong>filterOptions</strong> and a custom{' '}
|
When a relationship field has both **filterOptions** and a custom{' '}
|
||||||
<strong>validate</strong> function, the api will not validate <strong>filterOptions</strong>{' '}
|
**validate** function, the api will not validate **filterOptions**{' '}
|
||||||
unless you call the default relationship field validation function imported from{' '}
|
unless you call the default relationship field validation function imported from{' '}
|
||||||
<strong>payload/shared</strong> in your validate function.
|
**payload/shared** in your validate function.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
## Bi-directional relationships
|
## Bi-directional relationships
|
||||||
@@ -381,8 +381,8 @@ However, you **cannot** query on any field values within the related document.
|
|||||||
Since we are referencing multiple collections, the field you are querying on may not exist and break the query.
|
Since we are referencing multiple collections, the field you are querying on may not exist and break the query.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
You <strong>cannot</strong> query on a field within a polymorphic relationship as you would with a
|
You **cannot** query on a field within a polymorphic relationship as you would with a
|
||||||
non-polymorphic relationship.
|
non-polymorphic relationship.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export const MySelectField: Field = {
|
|||||||
_\* An asterisk denotes that a property is required._
|
_\* An asterisk denotes that a property is required._
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Option values should be strings that do not contain hyphens or special characters due to GraphQL
|
Option values should be strings that do not contain hyphens or special characters due to GraphQL
|
||||||
enumeration naming constraints. Underscores are allowed. If you determine you need your option
|
enumeration naming constraints. Underscores are allowed. If you determine you need your option
|
||||||
values to be non-strings or contain special characters, they will be formatted accordingly before
|
values to be non-strings or contain special characters, they will be formatted accordingly before
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const MyUploadField: Field = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
To use the Upload Field, you must have a [Collection](../configuration/collections) configured to allow [Uploads](../upload/overview).
|
To use the Upload Field, you must have a [Collection](../configuration/collections) configured to allow [Uploads](../upload/overview).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ export const MyUploadField: Field = {
|
|||||||
| Option | Description |
|
| Option | Description |
|
||||||
|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
|
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
|
||||||
| **`relationTo`** \* | Provide a single collection `slug` to allow this field to accept a relation to. <strong>Note: the related collection must be configured to support Uploads.</strong> |
|
| **`relationTo`** \* | Provide a single collection `slug` to allow this field to accept a relation to. **Note: the related collection must be configured to support Uploads.** |
|
||||||
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). |
|
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). |
|
||||||
| **`hasMany`** | Boolean which, if set to true, allows this field to have many relations instead of only one. |
|
| **`hasMany`** | Boolean which, if set to true, allows this field to have many relations instead of only one. |
|
||||||
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with hasMany. |
|
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with hasMany. |
|
||||||
@@ -125,12 +125,12 @@ const uploadField = {
|
|||||||
You can learn more about writing queries [here](/docs/queries/overview).
|
You can learn more about writing queries [here](/docs/queries/overview).
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
When an upload field has both <strong>filterOptions</strong> and a custom{' '}
|
When an upload field has both **filterOptions** and a custom{' '}
|
||||||
<strong>validate</strong> function, the api will not validate <strong>filterOptions</strong>{' '}
|
**validate** function, the api will not validate **filterOptions**{' '}
|
||||||
unless you call the default upload field validation function imported from{' '}
|
unless you call the default upload field validation function imported from{' '}
|
||||||
<strong>payload/shared</strong> in your validate function.
|
**payload/shared** in your validate function.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
## Bi-directional relationships
|
## Bi-directional relationships
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ Everything Payload does (create, read, update, delete, login, logout, etc.) is e
|
|||||||
- [GraphQL](#graphql) - A full GraphQL API with a GraphQL Playground
|
- [GraphQL](#graphql) - A full GraphQL API with a GraphQL Playground
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
All of these APIs share the exact same query language. [More details](../queries/overview).
|
All of these APIs share the exact same query language. [More details](../queries/overview).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ You can use any GraphQL client with Payload's GraphQL endpoint. Here are a few p
|
|||||||
Payload is abstracted into a set of dedicated packages to keep the core `payload` package as lightweight as possible. This allows you to only install the parts of Payload based on your unique project requirements.
|
Payload is abstracted into a set of dedicated packages to keep the core `payload` package as lightweight as possible. This allows you to only install the parts of Payload based on your unique project requirements.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Version numbers of all official Payload packages are always published in sync. You should make sure that you always use matching versions for all official Payload packages.
|
Version numbers of all official Payload packages are always published in sync. You should make sure that you always use matching versions for all official Payload packages.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -166,6 +166,6 @@ You can choose which Database Adapter you'd like to use for your project, and no
|
|||||||
Payload's Rich Text functionality is abstracted into separate packages and if you want to enable Rich Text in your project, you'll need to install one of these packages. We recommend Lexical for all new projects, and this is where Payload will focus its efforts on from this point, but Slate is still supported if you have already built with it.
|
Payload's Rich Text functionality is abstracted into separate packages and if you want to enable Rich Text in your project, you'll need to install one of these packages. We recommend Lexical for all new projects, and this is where Payload will focus its efforts on from this point, but Slate is still supported if you have already built with it.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
Rich Text is entirely optional and you may not need it for your project.
|
Rich Text is entirely optional and you may not need it for your project.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Payload requires the following software:
|
|||||||
- Any [compatible database](/docs/database/overview) (MongoDB, Postgres or SQLite)
|
- Any [compatible database](/docs/database/overview) (MongoDB, Postgres or SQLite)
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Before proceeding any further, please ensure that you have the above requirements met.
|
Before proceeding any further, please ensure that you have the above requirements met.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ Adding Payload to an existing Next.js app is super straightforward. You can eith
|
|||||||
If you don't have a Next.js app already, but you still want to start a project from a blank Next.js app, you can create a new Next.js app using `npx create-next-app` - and then just follow the steps below to install Payload.
|
If you don't have a Next.js app already, but you still want to start a project from a blank Next.js app, you can create a new Next.js app using `npx create-next-app` - and then just follow the steps below to install Payload.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong> Next.js version 15 or higher is required for Payload.
|
**Note:** Next.js version 15 or higher is required for Payload.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
#### 1. Install the relevant packages
|
#### 1. Install the relevant packages
|
||||||
@@ -48,7 +48,7 @@ pnpm i payload @payloadcms/next @payloadcms/richtext-lexical sharp graphql
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
Swap out `pnpm` for your package manager. If you are using npm, you might need to install using legacy peer deps: `npm i --legacy-peer-deps`.
|
Swap out `pnpm` for your package manager. If you are using npm, you might need to install using legacy peer deps: `npm i --legacy-peer-deps`.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ To install a Database Adapter, you can run **one** of the following commands:
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
New [Database Adapters](/docs/database/overview) are becoming available every day. Check the docs for the most up-to-date list of what's available.
|
New [Database Adapters](/docs/database/overview) are becoming available every day. Check the docs for the most up-to-date list of what's available.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ export default withPayload(nextConfig) // highlight-line
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Payload is a fully ESM project, and that means the `withPayload` function is an ECMAScript module.
|
Payload is a fully ESM project, and that means the `withPayload` function is an ECMAScript module.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ The above example outputs all your definitions to a file relative from your payl
|
|||||||
### Adding an npm script
|
### Adding an npm script
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important</strong>
|
**Important**
|
||||||
<br />
|
|
||||||
Payload needs to be able to find your config to generate your GraphQL schema.
|
Payload needs to be able to find your config to generate your GraphQL schema.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ GraphQL Playground is enabled by default for development purposes, but disabled
|
|||||||
You can even log in using the `login[collection-singular-label-here]` mutation to use the Playground as an authenticated user.
|
You can even log in using the `login[collection-singular-label-here]` mutation to use the Playground as an authenticated user.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br />
|
|
||||||
To see more regarding how the above queries and mutations are used, visit your GraphQL playground
|
To see more regarding how the above queries and mutations are used, visit your GraphQL playground
|
||||||
(by default at
|
(by default at
|
||||||
[`${SERVER_URL}/api/graphql-playground`](http://localhost:3000/api/graphql-playground))
|
[`${SERVER_URL}/api/graphql-playground`](http://localhost:3000/api/graphql-playground))
|
||||||
@@ -153,7 +153,7 @@ const NoProductionIntrospection: GraphQL.ValidationRule = (context) => ({
|
|||||||
{ nodes: [node] }
|
{ nodes: [node] }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const CollectionWithHooks: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
You can also set hooks on the field-level to isolate hook logic to specific fields. [More details](./fields).
|
You can also set hooks on the field-level to isolate hook logic to specific fields. [More details](./fields).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const FieldWithHooks: Field = {
|
|||||||
All Field Hooks accept an array of synchronous or asynchronous functions. These functions can optionally modify the return value of the field before the operation continues. All Field Hooks are formatted to accept the same arguments, although some arguments may be `undefined` based the specific hook type.
|
All Field Hooks accept an array of synchronous or asynchronous functions. These functions can optionally modify the return value of the field before the operation continues. All Field Hooks are formatted to accept the same arguments, although some arguments may be `undefined` based the specific hook type.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Due to GraphQL's typed nature, changing the type of data that you return from a field will produce errors in the [GraphQL API](../graphql/overview). If you need to change the shape or type of data, consider [Collection Hooks](./collections) or [Global Hooks](./hooks) instead.
|
Due to GraphQL's typed nature, changing the type of data that you return from a field will produce errors in the [GraphQL API](../graphql/overview). If you need to change the shape or type of data, consider [Collection Hooks](./collections) or [Global Hooks](./hooks) instead.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ The following arguments are provided to all Field Hooks:
|
|||||||
| **`value`** | The value of the [Field](../fields/overview). |
|
| **`value`** | The value of the [Field](../fields/overview). |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
It's a good idea to conditionally scope your logic based on which operation is executing. For example, if you are writing a `beforeChange` hook, you may want to perform different logic based on if the current `operation` is `create` or `update`.
|
It's a good idea to conditionally scope your logic based on which operation is executing. For example, if you are writing a `beforeChange` hook, you may want to perform different logic based on if the current `operation` is `create` or `update`.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const GlobalWithHooks: GlobalConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
You can also set hooks on the field-level to isolate hook logic to specific fields. [More details](./fields).
|
You can also set hooks on the field-level to isolate hook logic to specific fields. [More details](./fields).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ There are four main types of Hooks in Payload:
|
|||||||
- [Field Hooks](/docs/hooks/fields)
|
- [Field Hooks](/docs/hooks/fields)
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
Payload also ships a set of _React_ hooks that you can use in your frontend application. Although they share a common name, these are very different things and should not be confused. [More details](../admin/hooks).
|
Payload also ships a set of _React_ hooks that you can use in your frontend application. Although they share a common name, these are very different things and should not be confused. [More details](../admin/hooks).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ keywords: jobs queue, application framework, typescript, node, react, nextjs
|
|||||||
Now that we have covered Tasks and Workflows, we can tie them together with a concept called a Job.
|
Now that we have covered Tasks and Workflows, we can tie them together with a concept called a Job.
|
||||||
|
|
||||||
<Banner type="default">
|
<Banner type="default">
|
||||||
Whereas you define Workflows and Tasks, which control your business logic, a <strong>Job</strong> is an individual instance of either a Task or a Workflow which contains many tasks.
|
Whereas you define Workflows and Tasks, which control your business logic, a **Job** is an individual instance of either a Task or a Workflow which contains many tasks.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
For example, let's say we have a Workflow or Task that describes the logic to sync information from Payload to a third-party system. This is how you'd declare how to sync that info, but it wouldn't do anything on its own. In order to run that task or workflow, you'd create a Job that references the corresponding Task or Workflow.
|
For example, let's say we have a Workflow or Task that describes the logic to sync information from Payload to a third-party system. This is how you'd declare how to sync that info, but it wouldn't do anything on its own. In order to run that task or workflow, you'd create a Job that references the corresponding Task or Workflow.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ keywords: jobs queue, application framework, typescript, node, react, nextjs
|
|||||||
Queues are the final aspect of Payload's Jobs Queue and deal with how to _run your jobs_. Up to this point, all we've covered is how to queue up jobs to run, but so far, we aren't actually running any jobs.
|
Queues are the final aspect of Payload's Jobs Queue and deal with how to _run your jobs_. Up to this point, all we've covered is how to queue up jobs to run, but so far, we aren't actually running any jobs.
|
||||||
|
|
||||||
<Banner type="default">
|
<Banner type="default">
|
||||||
A <strong>Queue</strong> is a grouping of jobs that should be executed in order of when they were added.
|
A **Queue** is a grouping of jobs that should be executed in order of when they were added.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
When you go to run jobs, Payload will query for any jobs that are added to the queue and then run them. By default, all queued jobs are added to the `default` queue.
|
When you go to run jobs, Payload will query for any jobs that are added to the queue and then run them. By default, all queued jobs are added to the `default` queue.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ keywords: jobs queue, application framework, typescript, node, react, nextjs
|
|||||||
---
|
---
|
||||||
|
|
||||||
<Banner type="default">
|
<Banner type="default">
|
||||||
A <strong>"Task"</strong> is a function definition that performs business logic and whose input and output are both strongly typed.
|
A **"Task"** is a function definition that performs business logic and whose input and output are both strongly typed.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
You can register Tasks on the Payload config, and then create [Jobs](/docs/jobs-queue/jobs) or [Workflows](/docs/jobs-queue/workflows) that use them. Think of Tasks like tidy, isolated "functions that do one specific thing".
|
You can register Tasks on the Payload config, and then create [Jobs](/docs/jobs-queue/jobs) or [Workflows](/docs/jobs-queue/workflows) that use them. Think of Tasks like tidy, isolated "functions that do one specific thing".
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ keywords: jobs queue, application framework, typescript, node, react, nextjs
|
|||||||
---
|
---
|
||||||
|
|
||||||
<Banner type="default">
|
<Banner type="default">
|
||||||
A <strong>"Workflow"</strong> is an optional way to <em>combine multiple tasks together</em> in a way that can be gracefully retried from the point of failure.
|
A **"Workflow"** is an optional way to *combine multiple tasks together* in a way that can be gracefully retried from the point of failure.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
They're most helpful when you have multiple tasks in a row, and you want to configure each task to be able to be retried if they fail.
|
They're most helpful when you have multiple tasks in a row, and you want to configure each task to be able to be retried if they fail.
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export const PageClient: React.FC<{
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
If you are using [React Server Components](https://react.dev/reference/rsc/server-components), we strongly suggest setting up [server-side Live Preview](./server) instead.
|
If you are using [React Server Components](https://react.dev/reference/rsc/server-components), we strongly suggest setting up [server-side Live Preview](./server) instead.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ const config = buildConfig({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
Alternatively, you can define the <code>admin.livePreview</code> property on individual [Collection Admin Configs](../admin/collections) and [Global Admin Configs](../admin/globals). Settings defined here will be merged into the top-level as overrides.
|
Alternatively, you can define the `admin.livePreview` property on individual [Collection Admin Configs](../admin/collections) and [Global Admin Configs](../admin/globals). Settings defined here will be merged into the top-level as overrides.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
{/* IMAGE OF LIVE PREVIEW HERE */}
|
{/* IMAGE OF LIVE PREVIEW HERE */}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ keywords: local api, config, configuration, documentation, Content Management Sy
|
|||||||
Payload can be used completely outside of Next.js which is helpful in cases like running scripts, using Payload in a separate backend service, or using Payload's Local API to fetch your data directly from your database in other frontend frameworks like SvelteKit, Remix, Nuxt, and similar.
|
Payload can be used completely outside of Next.js which is helpful in cases like running scripts, using Payload in a separate backend service, or using Payload's Local API to fetch your data directly from your database in other frontend frameworks like SvelteKit, Remix, Nuxt, and similar.
|
||||||
|
|
||||||
<Banner>
|
<Banner>
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br/>
|
<br/>
|
||||||
Payload and all of its official packages are fully ESM. If you want to use Payload within your own projects, make sure you are writing your scripts in ESM format or dynamically importing the Payload Config.
|
Payload and all of its official packages are fully ESM. If you want to use Payload within your own projects, make sure you are writing your scripts in ESM format or dynamically importing the Payload Config.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ keywords: local api, config, configuration, documentation, Content Management Sy
|
|||||||
The Payload Local API gives you the ability to execute the same operations that are available through REST and GraphQL within Node, directly on your server. Here, you don't need to deal with server latency or network speed whatsoever and can interact directly with your database.
|
The Payload Local API gives you the ability to execute the same operations that are available through REST and GraphQL within Node, directly on your server. Here, you don't need to deal with server latency or network speed whatsoever and can interact directly with your database.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br />
|
|
||||||
The Local API is incredibly powerful when used in React Server Components and other similar server-side contexts. With other headless CMS, you need to request your data from third-party servers via an HTTP layer, which can add significant loading time to your server-rendered pages. With Payload, you don't have to leave your server to gather the data you need. It can be incredibly fast and is definitely a game changer.
|
The Local API is incredibly powerful when used in React Server Components and other similar server-side contexts. With other headless CMS, you need to request your data from third-party servers via an HTTP layer, which can add significant loading time to your server-rendered pages. With Payload, you don't have to leave your server to gather the data you need. It can be incredibly fast and is definitely a game changer.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ const post = await payload.find({
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
By default, all access control checks are disabled in the Local API, but you can re-enable them if
|
By default, all access control checks are disabled in the Local API, but you can re-enable them if
|
||||||
you'd like, as well as pass a specific user to run the operation with.
|
you'd like, as well as pass a specific user to run the operation with.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ formBuilderPlugin({
|
|||||||
Each field represents a form input. To override default settings pass either a boolean value or a partial [Payload Block](https://payloadcms.com/docs/fields/blocks) _keyed to the block's slug_. See [Field Overrides](#field-overrides) for more details on how to do this.
|
Each field represents a form input. To override default settings pass either a boolean value or a partial [Payload Block](https://payloadcms.com/docs/fields/blocks) _keyed to the block's slug_. See [Field Overrides](#field-overrides) for more details on how to do this.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
"Fields" here is in reference to the _fields to build forms with_, not to be confused with the _fields
|
"Fields" here is in reference to the _fields to build forms with_, not to be confused with the _fields
|
||||||
of a collection_ which are set via `formOverrides.fields`.
|
of a collection_ which are set via `formOverrides.fields`.
|
||||||
</Banner>
|
</Banner>
|
||||||
@@ -458,13 +458,13 @@ Below are some common troubleshooting tips. To help other developers, please con
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br />
|
|
||||||

|

|
||||||
<br />
|
|
||||||

|

|
||||||
<br />
|
|
||||||

|

|
||||||
<br />
|
|
||||||

|

|
||||||
<br />
|
|
||||||

|

|
||||||
|
|||||||
@@ -163,8 +163,8 @@ When defined, the `breadcrumbs` field will not be provided for you, and instead,
|
|||||||
own `breadcrumbs` field to each collection manually. Set this property to the `name` of your custom field.
|
own `breadcrumbs` field to each collection manually. Set this property to the `name` of your custom field.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
If you opt out of automatically being provided a `parent` or `breadcrumbs` field, you need to make
|
If you opt out of automatically being provided a `parent` or `breadcrumbs` field, you need to make
|
||||||
sure that both fields are placed at the top-level of your document. They cannot exist within any
|
sure that both fields are placed at the top-level of your document. They cannot exist within any
|
||||||
nested data structures like a `group`, `array`, or `blocks`.
|
nested data structures like a `group`, `array`, or `blocks`.
|
||||||
@@ -215,8 +215,8 @@ const examplePageConfig: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
If overriding the `name` of either `breadcrumbs` or `parent` fields, you must specify the
|
If overriding the `name` of either `breadcrumbs` or `parent` fields, you must specify the
|
||||||
`breadcrumbsFieldSlug` or `parentFieldSlug` respectively.
|
`breadcrumbsFieldSlug` or `parentFieldSlug` respectively.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -147,6 +147,6 @@ export const addLastModified: Plugin = (incomingConfig: Config): Config => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
See [how to build your own plugin](./build-your-own) for a more in-depth explication on how create your own Payload Plugin.
|
See [how to build your own plugin](./build-your-own) for a more in-depth explication on how create your own Payload Plugin.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -109,15 +109,15 @@ const res = await fetch(`/api/stripe/rest`, {
|
|||||||
If you need to proxy the API server-side, use the [stripeProxy](#node) function.
|
If you need to proxy the API server-side, use the [stripeProxy](#node) function.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
The `/api` part of these routes may be different based on the settings defined in your Payload
|
The `/api` part of these routes may be different based on the settings defined in your Payload
|
||||||
config.
|
config.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Warning:</strong>
|
**Warning:**
|
||||||
<br />
|
|
||||||
Opening the REST proxy endpoint in production is a potential security risk. Authenticated users will have open access to the Stripe REST API. In production, open your own endpoint and use the [stripeProxy](#node) function to proxy the Stripe API server-side.
|
Opening the REST proxy endpoint in production is a potential security risk. Authenticated users will have open access to the Stripe REST API. In production, open your own endpoint and use the [stripeProxy](#node) function to proxy the Stripe API server-side.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -232,8 +232,8 @@ export const MyFunction = async () => {
|
|||||||
This option will setup a basic sync between Payload collections and Stripe resources for you automatically. It will create all the necessary hooks and webhooks handlers, so the only thing you have to do is map your Payload fields to their corresponding Stripe properties. As documents are created, updated, and deleted from either Stripe or Payload, the changes are reflected on either side.
|
This option will setup a basic sync between Payload collections and Stripe resources for you automatically. It will create all the necessary hooks and webhooks handlers, so the only thing you have to do is map your Payload fields to their corresponding Stripe properties. As documents are created, updated, and deleted from either Stripe or Payload, the changes are reflected on either side.
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
If you wish to enable a _two-way_ sync, be sure to setup [`webhooks`](#webhooks) and pass the
|
If you wish to enable a _two-way_ sync, be sure to setup [`webhooks`](#webhooks) and pass the
|
||||||
`stripeWebhooksEndpointSecret` through your config.
|
`stripeWebhooksEndpointSecret` through your config.
|
||||||
</Banner>
|
</Banner>
|
||||||
@@ -268,8 +268,8 @@ export default config
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
Due to limitations in the Stripe API, this currently only works with top-level fields. This is
|
Due to limitations in the Stripe API, this currently only works with top-level fields. This is
|
||||||
because every Stripe object is a separate entity, making it difficult to abstract into a simple
|
because every Stripe object is a separate entity, making it difficult to abstract into a simple
|
||||||
reusable library. In the future, we may find a pattern around this. But for now, cases like that
|
reusable library. In the future, we may find a pattern around this. But for now, cases like that
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ keywords: deployment, production, config, configuration, documentation, Content
|
|||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
So you've developed a Payload app, it's fully tested, and running great locally. Now it's time to
|
So you've developed a Payload app, it's fully tested, and running great locally. Now it's time to
|
||||||
launch. <strong>Awesome! Great work!</strong> Now, what's next?
|
launch. **Awesome! Great work!** Now, what's next?
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
There are many ways to deploy Payload to a production environment. When evaluating how you will deploy Payload, you need
|
There are many ways to deploy Payload to a production environment. When evaluating how you will deploy Payload, you need
|
||||||
@@ -55,17 +55,17 @@ Because _**you**_ are in complete control of who can do what with your data, you
|
|||||||
wield that power responsibly before deploying to Production.
|
wield that power responsibly before deploying to Production.
|
||||||
|
|
||||||
<Banner type="error">
|
<Banner type="error">
|
||||||
<strong>
|
**
|
||||||
By default, all Access Control functions require that a user is successfully logged in to
|
By default, all Access Control functions require that a user is successfully logged in to
|
||||||
Payload to create, read, update, or delete data.
|
Payload to create, read, update, or delete data.
|
||||||
</strong>
|
**
|
||||||
But, if you allow public user registration, for example, you will want to make sure that your
|
But, if you allow public user registration, for example, you will want to make sure that your
|
||||||
access control functions are more strict - permitting
|
access control functions are more strict - permitting
|
||||||
{' '}
|
|
||||||
<strong>
|
**
|
||||||
only appropriate users
|
only appropriate users
|
||||||
</strong>
|
**
|
||||||
{' '}
|
|
||||||
to perform appropriate actions.
|
to perform appropriate actions.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -133,9 +133,9 @@ perpetually.
|
|||||||
- Many other more traditional web hosts
|
- Many other more traditional web hosts
|
||||||
|
|
||||||
<Banner type="error">
|
<Banner type="error">
|
||||||
<strong>Warning:</strong>
|
**Warning:**
|
||||||
<br />
|
|
||||||
If you rely on Payload's <strong>Upload</strong> functionality, make sure you either use a host
|
If you rely on Payload's **Upload** functionality, make sure you either use a host
|
||||||
with a persistent filesystem or have an integration with a third-party file host like Amazon S3.
|
with a persistent filesystem or have an integration with a third-party file host like Amazon S3.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ But with a `depth` of `1`, the response might look like this:
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
Depth has no effect in the [GraphQL API](../graphql/overview), because there, depth is based on the shape of your queries.
|
Depth has no effect in the [GraphQL API](../graphql/overview), because there, depth is based on the shape of your queries.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ const getPosts = async (payload: Payload) => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
This is the same for [Globals](../configuration/globals) using the `findGlobal` operation.
|
This is the same for [Globals](../configuration/globals) using the `findGlobal` operation.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ fetch('https://localhost:3000/api/posts?depth=2') // highlight-line
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
This is the same for [Globals](../configuration/globals) using the `/api/globals` endpoint.
|
This is the same for [Globals](../configuration/globals) using the `/api/globals` endpoint.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const query: Where = {
|
|||||||
_The exact query syntax will depend on the API you are using, but the concepts are the same across all APIs. [More details](#writing-queries)._
|
_The exact query syntax will depend on the API you are using, but the concepts are the same across all APIs. [More details](#writing-queries)._
|
||||||
|
|
||||||
<Banner>
|
<Banner>
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
You can also use queries within [Access Control](../access-control/overview) functions.
|
You can also use queries within [Access Control](../access-control/overview) functions.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ The following operators are available for use in queries:
|
|||||||
| `intersects` | For [Point Fields](../fields/point) to filter documents based on whether points intersect with the given area defined in GeoJSON. [Example](../fields/point#querying-intersects) |
|
| `intersects` | For [Point Fields](../fields/point) to filter documents based on whether points intersect with the given area defined in GeoJSON. [Example](../fields/point#querying-intersects) |
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
If you know your users will be querying on certain fields a lot, add `index: true` to the Field Config. This will speed up searches using that field immensely.
|
If you know your users will be querying on certain fields a lot, add `index: true` to the Field Config. This will speed up searches using that field immensely.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const getPosts = async (payload: Payload) => {
|
|||||||
|
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
To perform querying with `select` efficiently, Payload implements your `select` query on the database level. Because of that, your `beforeRead` and `afterRead` hooks may not receive the full `doc`.
|
To perform querying with `select` efficiently, Payload implements your `select` query on the database level. Because of that, your `beforeRead` and `afterRead` hooks may not receive the full `doc`.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ const getPosts = async () => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="info">
|
<Banner type="info">
|
||||||
<strong>Reminder:</strong>
|
**Reminder:**
|
||||||
This is the same for [Globals](../configuration/globals) using the `/api/globals` endpoint.
|
This is the same for [Globals](../configuration/globals) using the `/api/globals` endpoint.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Documents in Payload can be easily sorted by a specific [Field](../fields/overvi
|
|||||||
Because sorting is handled by the database, the field cannot be a [Virtual Field](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges). It must be stored in the database to be searchable.
|
Because sorting is handled by the database, the field cannot be a [Virtual Field](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges). It must be stored in the database to be searchable.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
For performance reasons, it is recommended to enable `index: true` for the fields that will be sorted upon. [More details](../fields/overview).
|
For performance reasons, it is recommended to enable `index: true` for the fields that will be sorted upon. [More details](../fields/overview).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ export const Orders: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner>
|
<Banner>
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
**req** will have the **payload** object and can be used inside your endpoint handlers for making calls like req.payload.find() that will make use of [Access Control](../access-control/overview) and [Hooks](../hooks/overview).
|
**req** will have the **payload** object and can be used inside your endpoint handlers for making calls like req.payload.find() that will make use of [Access Control](../access-control/overview) and [Hooks](../hooks/overview).
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -380,9 +380,9 @@ Functions prefixed with a `$` can only be run inside an `editor.update()` or `ed
|
|||||||
This has been taken from the [lexical serialization & deserialization docs](https://lexical.dev/docs/concepts/serialization#html---lexical).
|
This has been taken from the [lexical serialization & deserialization docs](https://lexical.dev/docs/concepts/serialization#html---lexical).
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
Using the <code>discrete: true</code> flag ensures instant updates to the editor state. If
|
Using the `discrete: true` flag ensures instant updates to the editor state. If
|
||||||
immediate reading of the updated state isn't necessary, you can omit the flag.
|
immediate reading of the updated state isn't necessary, you can omit the flag.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -123,12 +123,12 @@ The built-in `relationship` element is a powerful way to reference other Documen
|
|||||||
Similar to the `relationship` element, the `upload` element is a user-friendly way to reference [Upload-enabled collections](/docs/upload/overview) with a UI specifically designed for media / image-based uploads.
|
Similar to the `relationship` element, the `upload` element is a user-friendly way to reference [Upload-enabled collections](/docs/upload/overview) with a UI specifically designed for media / image-based uploads.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br />
|
|
||||||
Collections are automatically allowed to be selected within the Rich Text relationship and upload
|
Collections are automatically allowed to be selected within the Rich Text relationship and upload
|
||||||
elements by default. If you want to disable a collection from being able to be referenced in Rich
|
elements by default. If you want to disable a collection from being able to be referenced in Rich
|
||||||
Text fields, set the collection admin options of <strong>enableRichTextLink</strong> and{' '}
|
Text fields, set the collection admin options of **enableRichTextLink** and{' '}
|
||||||
<strong>enableRichTextRelationship</strong> to false.
|
**enableRichTextRelationship** to false.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
Relationship and Upload elements are populated dynamically into your Rich Text field' content. Within the REST and Local APIs, any present RichText `relationship` or `upload` elements will respect the `depth` option that you pass, and will be populated accordingly. In GraphQL, each `richText` field accepts an argument of `depth` for you to utilize.
|
Relationship and Upload elements are populated dynamically into your Rich Text field' content. Within the REST and Local APIs, any present RichText `relationship` or `upload` elements will respect the `depth` option that you pass, and will be populated accordingly. In GraphQL, each `richText` field accepts an argument of `depth` for you to utilize.
|
||||||
@@ -306,8 +306,8 @@ const serialize = (children) =>
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner>
|
<Banner>
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
The above example is for how to render to JSX, although for plain HTML the pattern is similar.
|
The above example is for how to render to JSX, although for plain HTML the pattern is similar.
|
||||||
Just remove the JSX and return HTML strings instead!
|
Just remove the JSX and return HTML strings instead!
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -201,8 +201,8 @@ export interface Collection1 {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Naming Collisions</strong>
|
**Naming Collisions**
|
||||||
<br />
|
|
||||||
Since these types are hoisted to the top level, you need to be aware that naming collisions can
|
Since these types are hoisted to the top level, you need to be aware that naming collisions can
|
||||||
occur. For example, if you have a collection with the name of `Meta` and you also create a
|
occur. For example, if you have a collection with the name of `Meta` and you also create a
|
||||||
interface with the name `Meta` they will collide. It is recommended to scope your interfaces by
|
interface with the name `Meta` they will collide. It is recommended to scope your interfaces by
|
||||||
@@ -216,8 +216,8 @@ Now that your types have been generated, payloads local API will now be typed. I
|
|||||||
### Adding an npm script
|
### Adding an npm script
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important</strong>
|
**Important**
|
||||||
<br />
|
|
||||||
Payload needs to be able to find your config to generate your types.
|
Payload needs to be able to find your config to generate your types.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,9 @@ keywords: uploads, images, media, overview, documentation, Content Management Sy
|
|||||||
Every Payload Collection can opt-in to supporting Uploads by specifying the `upload` property on the Collection's config to either `true` or to an object containing `upload` options.
|
Every Payload Collection can opt-in to supporting Uploads by specifying the `upload` property on the Collection's config to either `true` or to an object containing `upload` options.
|
||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
<strong>Tip:</strong>
|
**Tip:**
|
||||||
<br />A common pattern is to create a <strong>"media"</strong> collection and enable <strong>
|
|
||||||
upload
|
A common pattern is to create a **"media"** collection and enable **upload** on that collection.
|
||||||
</strong> on that collection.
|
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@@ -182,8 +181,8 @@ When an uploaded image is smaller than the defined image size, we have 3 options
|
|||||||
3. `true`: if the image is smaller than the image size, return the original image
|
3. `true`: if the image is smaller than the image size, return the original image
|
||||||
|
|
||||||
<Banner type="error">
|
<Banner type="error">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
By default, the image size will return NULL when the uploaded image is smaller than the defined
|
By default, the image size will return NULL when the uploaded image is smaller than the defined
|
||||||
image size. Use the `withoutEnlargement` prop to change this.
|
image size. Use the `withoutEnlargement` prop to change this.
|
||||||
</Banner>
|
</Banner>
|
||||||
@@ -219,12 +218,12 @@ If no resizing options are specified (`imageSizes` or `resizeOptions`), the foca
|
|||||||
If you are using a plugin to send your files off to a third-party file storage host or CDN, like Amazon S3 or similar, you may not want to store your files locally at all. You can prevent Payload from writing files to disk by specifying `disableLocalStorage: true` on your collection's upload config.
|
If you are using a plugin to send your files off to a third-party file storage host or CDN, like Amazon S3 or similar, you may not want to store your files locally at all. You can prevent Payload from writing files to disk by specifying `disableLocalStorage: true` on your collection's upload config.
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note:</strong>
|
**Note:**
|
||||||
<br />
|
|
||||||
This is a fairly advanced feature. If you do disable local file storage, by default, your admin
|
This is a fairly advanced feature. If you do disable local file storage, by default, your admin
|
||||||
panel's thumbnails will be broken as you will not have stored a file. It will be totally up to you
|
panel's thumbnails will be broken as you will not have stored a file. It will be totally up to you
|
||||||
to use either a plugin or your own hooks to store your files in a permanent manner, as well as
|
to use either a plugin or your own hooks to store your files in a permanent manner, as well as
|
||||||
provide your own admin thumbnail using <strong>upload.adminThumbnail</strong>.
|
provide your own admin thumbnail using **upload.adminThumbnail**.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
## Admin Thumbnails
|
## Admin Thumbnails
|
||||||
@@ -297,8 +296,8 @@ export const Media: CollectionConfig = {
|
|||||||
## Uploading Files
|
## Uploading Files
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Important:</strong>
|
**Important:**
|
||||||
<br />
|
|
||||||
Uploading files is currently only possible through the REST and Local APIs due to how GraphQL
|
Uploading files is currently only possible through the REST and Local APIs due to how GraphQL
|
||||||
works. It's difficult and fairly nonsensical to support uploading files through GraphQL.
|
works. It's difficult and fairly nonsensical to support uploading files through GraphQL.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -70,6 +70,6 @@ If we created a new version for each autosave, you'd quickly find a ton of autos
|
|||||||
|
|
||||||
<Banner type="success">
|
<Banner type="success">
|
||||||
Instead of creating a new version each time a document is autosaved, Payload smartly only creates{' '}
|
Instead of creating a new version each time a document is autosaved, Payload smartly only creates{' '}
|
||||||
<strong>one</strong> autosave version, and then updates that specific version with each autosave
|
**one** autosave version, and then updates that specific version with each autosave
|
||||||
performed. This makes sure that your versions remain nice and tidy.
|
performed. This makes sure that your versions remain nice and tidy.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|||||||
@@ -26,16 +26,16 @@ Collections and Globals both support the same options for configuring drafts. Yo
|
|||||||
|
|
||||||
## Database changes
|
## Database changes
|
||||||
|
|
||||||
By enabling drafts on a collection or a global, Payload will <strong>automatically inject a new field into your schema</strong> called `_status`. The `_status` field is used internally by Payload to store if a document is set to `draft` or `published`.
|
By enabling drafts on a collection or a global, Payload will **automatically inject a new field into your schema** called `_status`. The `_status` field is used internally by Payload to store if a document is set to `draft` or `published`.
|
||||||
|
|
||||||
**Admin UI status indication**
|
**Admin UI status indication**
|
||||||
|
|
||||||
Within the Admin UI, if drafts are enabled, a document can be shown with one of three "statuses":
|
Within the Admin UI, if drafts are enabled, a document can be shown with one of three "statuses":
|
||||||
|
|
||||||
1. <strong>Draft</strong> - if a document has never been published, and only draft versions of the document
|
1. **Draft** - if a document has never been published, and only draft versions of the document
|
||||||
are present
|
are present
|
||||||
1. <strong>Published</strong> - if a document is published and there are no newer drafts available
|
1. **Published** - if a document is published and there are no newer drafts available
|
||||||
1. <strong>Changed</strong> - if a document has been published, but there are newer drafts available
|
1. **Changed** - if a document has been published, but there are newer drafts available
|
||||||
and not yet published
|
and not yet published
|
||||||
|
|
||||||
## Draft API
|
## Draft API
|
||||||
@@ -48,7 +48,7 @@ Within the Admin UI, if drafts are enabled, a document can be shown with one of
|
|||||||
|
|
||||||
#### Updating or creating drafts
|
#### Updating or creating drafts
|
||||||
|
|
||||||
If you enable drafts on a collection or global, the `create` and `update` operations for REST, GraphQL, and Local APIs expose a new option called `draft` which allows you to specify if you are creating or updating a <strong>draft</strong>, or if you're just sending your changes straight to the published document. For example, if you pass the query parameter `?draft=true` to a REST `create` or `update` operation, your action will be treated as if you are creating a `draft` and not a published document. By default, the `draft` argument is set to `false`.
|
If you enable drafts on a collection or global, the `create` and `update` operations for REST, GraphQL, and Local APIs expose a new option called `draft` which allows you to specify if you are creating or updating a **draft**, or if you're just sending your changes straight to the published document. For example, if you pass the query parameter `?draft=true` to a REST `create` or `update` operation, your action will be treated as if you are creating a `draft` and not a published document. By default, the `draft` argument is set to `false`.
|
||||||
|
|
||||||
**Required fields**
|
**Required fields**
|
||||||
|
|
||||||
@@ -58,9 +58,9 @@ If `draft` is enabled while creating or updating a document, all fields are cons
|
|||||||
|
|
||||||
In addition to the `draft` argument within `create` and `update` operations, a `draft` argument is also exposed for `find` and `findByID` operations.
|
In addition to the `draft` argument within `create` and `update` operations, a `draft` argument is also exposed for `find` and `findByID` operations.
|
||||||
|
|
||||||
If `draft` is set to `true` while reading a document, <strong>Payload will automatically replace returned document(s) with their newest drafts</strong> if any newer drafts are available.
|
If `draft` is set to `true` while reading a document, **Payload will automatically replace returned document(s) with their newest drafts** if any newer drafts are available.
|
||||||
|
|
||||||
<strong>For example, let's take the following scenario:</strong>
|
**For example, let's take the following scenario:**
|
||||||
|
|
||||||
1. You create a new collection document and publish it right away
|
1. You create a new collection document and publish it right away
|
||||||
1. You then make some updates, and save the updates as a draft
|
1. You then make some updates, and save the updates as a draft
|
||||||
@@ -75,7 +75,7 @@ But, if you specify `draft` as `true`, Payload will automatically replace your p
|
|||||||
## Controlling who can see Collection drafts
|
## Controlling who can see Collection drafts
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
If you're using the <strong>drafts</strong> feature, it's important for you to consider who can
|
If you're using the **drafts** feature, it's important for you to consider who can
|
||||||
view your drafts, and who can view only published documents. Luckily, Payload makes this extremely
|
view your drafts, and who can view only published documents. Luckily, Payload makes this extremely
|
||||||
simple and puts the power completely in your hands.
|
simple and puts the power completely in your hands.
|
||||||
</Banner>
|
</Banner>
|
||||||
@@ -115,15 +115,15 @@ export const Pages: CollectionConfig = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<Banner type="warning">
|
<Banner type="warning">
|
||||||
<strong>Note regarding adding versions to an existing collection</strong>
|
**Note regarding adding versions to an existing collection**
|
||||||
<br />
|
|
||||||
If you already have a collection with documents, and you <em>opt in</em> to draft functionality
|
If you already have a collection with documents, and you *opt in* to draft functionality
|
||||||
after you have already created existing documents, all of your old documents{' '}
|
after you have already created existing documents, all of your old documents{' '}
|
||||||
<em>will not have a _status field</em> until you resave them. For this reason, if you are{' '}
|
*will not have a _status field* until you resave them. For this reason, if you are{' '}
|
||||||
<em>adding</em> versions into an existing collection, you might want to write your Access Control
|
*adding* versions into an existing collection, you might want to write your Access Control
|
||||||
function to allow for users to read both documents where{' '}
|
function to allow for users to read both documents where{' '}
|
||||||
<strong>_status is equal to "published"</strong> as well as where{' '}
|
**status is equal to "published"** as well as where{' '}
|
||||||
<strong>_status does not exist</strong>.
|
**status does not exis**.
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
Here is an example for how to write an [Access Control](../access-control/overview) function that grants access to both documents where `_status` is equal to "published" and where `_status` does not exist:
|
Here is an example for how to write an [Access Control](../access-control/overview) function that grants access to both documents where `_status` is equal to "published" and where `_status` does not exist:
|
||||||
|
|||||||
Reference in New Issue
Block a user