chore: misc documentation updates (#2589)
* chore: ensures example configs are being exported when necessary * chore: adds note regarding updating of hidden fields --------- Co-authored-by: Jessica Boezwinkle <jessica@trbl.design>
This commit is contained in:
@@ -30,7 +30,7 @@ If a Collection supports [`Authentication`](/docs/authentication/overview), the
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Posts: CollectionConfig = {
|
export const Posts: CollectionConfig = {
|
||||||
slug: "posts",
|
slug: "posts",
|
||||||
// highlight-start
|
// highlight-start
|
||||||
access: {
|
access: {
|
||||||
@@ -42,8 +42,6 @@ const Posts: CollectionConfig = {
|
|||||||
},
|
},
|
||||||
// highlight-end
|
// highlight-end
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Posts;
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create
|
### Create
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Field Access Control is specified with functions inside a field's config. All fi
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Posts: CollectionConfig = {
|
export const Posts: CollectionConfig = {
|
||||||
slug: 'posts',
|
slug: 'posts',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -67,6 +67,8 @@ Returns a boolean which allows or denies the ability to read a field's value. If
|
|||||||
|
|
||||||
Returns a boolean which allows or denies the ability to update a field's value. If `false` is returned, any passed values will be discarded.
|
Returns a boolean which allows or denies the ability to update a field's value. If `false` is returned, any passed values will be discarded.
|
||||||
|
|
||||||
|
If `false` is returned and you attempt to update the field's value, the operation will **not** throw an error however the field will be omitted from the update operation and the value will remain unchanged.
|
||||||
|
|
||||||
**Available argument properties:**
|
**Available argument properties:**
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ You may rely on server-only packages such as the above to perform logic in acces
|
|||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
import createStripeSubscription from './hooks/createStripeSubscription';
|
import createStripeSubscription from './hooks/createStripeSubscription';
|
||||||
|
|
||||||
const Subscription: CollectionConfig = {
|
export const Subscription: CollectionConfig = {
|
||||||
slug: 'subscriptions',
|
slug: 'subscriptions',
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeChange: [
|
beforeChange: [
|
||||||
@@ -71,8 +71,6 @@ const Subscription: CollectionConfig = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Subscription;
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The collection above features a `beforeChange` hook that creates a Stripe subscription whenever a Subscription document is created in Payload.
|
The collection above features a `beforeChange` hook that creates a Stripe subscription whenever a Subscription document is created in Payload.
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Example:
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Customers: CollectionConfig = {
|
export const Customers: CollectionConfig = {
|
||||||
slug: 'customers',
|
slug: 'customers',
|
||||||
auth: {
|
auth: {
|
||||||
forgotPassword: {
|
forgotPassword: {
|
||||||
@@ -156,7 +156,7 @@ Example:
|
|||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
|
|
||||||
const Customers: CollectionConfig = {
|
export const Customers: CollectionConfig = {
|
||||||
slug: 'customers',
|
slug: 'customers',
|
||||||
auth: {
|
auth: {
|
||||||
verify: {
|
verify: {
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ Simple example collection:
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Admins: CollectionConfig = {
|
export const Admins: CollectionConfig = {
|
||||||
slug:
|
slug: 'admins',
|
||||||
// highlight-start
|
// highlight-start
|
||||||
auth: {
|
auth: {
|
||||||
tokenExpiration: 7200, // How many seconds to keep the user logged in
|
tokenExpiration: 7200, // How many seconds to keep the user logged in
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ It's often best practice to write your Collections in separate files and then im
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Orders: CollectionConfig = {
|
export const Orders: CollectionConfig = {
|
||||||
slug: 'orders',
|
slug: 'orders',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ If the function is specified, a Preview button will automatically appear in the
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Posts: CollectionConfig = {
|
export const Posts: CollectionConfig = {
|
||||||
slug: 'posts',
|
slug: 'posts',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ If the function is specified, a Preview button will automatically appear in the
|
|||||||
```ts
|
```ts
|
||||||
import { GlobalConfig } from "payload/types";
|
import { GlobalConfig } from "payload/types";
|
||||||
|
|
||||||
const MyGlobal: GlobalConfig = {
|
export const MyGlobal: GlobalConfig = {
|
||||||
slug: "my-global",
|
slug: "my-global",
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ While Payload's built-in features come translated, you may want to also translat
|
|||||||
|
|
||||||
Here is an example of a simple collection supporting both English and Spanish editors:
|
Here is an example of a simple collection supporting both English and Spanish editors:
|
||||||
```ts
|
```ts
|
||||||
const Articles: CollectionConfig = {
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
|
export const Articles: CollectionConfig = {
|
||||||
slug: 'articles',
|
slug: 'articles',
|
||||||
labels: {
|
labels: {
|
||||||
singular: {
|
singular: {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ const QuoteBlock: Block = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ When only `pickerAppearance` is set, an equivalent format will be rendered in th
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: "example-collection",
|
slug: "example-collection",
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ Set this property to a string that will be used for browser autocomplete.
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ Set this property to `true` to hide this field's gutter within the admin panel.
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Set this property to a string that will be used for browser autocomplete.
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ The required `type` property on a field determines what values it can accept, ho
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Page: CollectionConfig = {
|
export const Page: CollectionConfig = {
|
||||||
slug: 'pages',
|
slug: 'pages',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -90,7 +90,7 @@ Example:
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Orders: CollectionConfig = {
|
export const Orders: CollectionConfig = {
|
||||||
slug: 'orders',
|
slug: 'orders',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ The data structure in the database matches the GeoJSON structure to represent po
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ The `layout` property allows for the radio group to be styled as a horizonally o
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -73,5 +73,4 @@ const ExampleCollection: CollectionConfig = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
|
|||||||
### Config
|
### Config
|
||||||
|
|
||||||
| 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 one or many collection `slug`s to be able to assign relationships to. |
|
| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. |
|
||||||
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
|
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
|
||||||
@@ -77,27 +77,34 @@ The `filterOptions` property can either be a `Where` query directly, or a functi
|
|||||||
| `id` | The value of the collection `id`, will be `undefined` on create request |
|
| `id` | The value of the collection `id`, will be `undefined` on create request |
|
||||||
| `user` | The currently authenticated user object |
|
| `user` | The currently authenticated user object |
|
||||||
|
|
||||||
**Example:**
|
### Example
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const relationshipField = {
|
import { CollectionConfig } from "payload/types";
|
||||||
name: "purchase",
|
|
||||||
type: "relationship",
|
|
||||||
relationTo: ["products", "services"],
|
|
||||||
filterOptions: ({ relationTo, siblingData }) => {
|
|
||||||
// returns a Where query dynamically by the type of relationship
|
|
||||||
if (relationTo === "products") {
|
|
||||||
return {
|
|
||||||
stock: { greater_than: siblingData.quantity },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relationTo === "services") {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
return {
|
slug: "example-collection",
|
||||||
isAvailable: { equals: true },
|
fields: [
|
||||||
};
|
{
|
||||||
}
|
name: "purchase",
|
||||||
},
|
type: "relationship",
|
||||||
|
relationTo: ["products", "services"],
|
||||||
|
filterOptions: ({ relationTo, siblingData }) => {
|
||||||
|
// returns a Where query dynamically by the type of relationship
|
||||||
|
if (relationTo === "products") {
|
||||||
|
return {
|
||||||
|
stock: { greater_than: siblingData.quantity },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relationTo === "services") {
|
||||||
|
return {
|
||||||
|
isAvailable: { equals: true },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ Custom `Leaf` objects follow a similar pattern but require you to define the `Le
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -371,5 +371,4 @@ import type {
|
|||||||
RichTextCustomElement,
|
RichTextCustomElement,
|
||||||
RichTextCustomLeaf,
|
RichTextCustomLeaf,
|
||||||
} from 'payload/types';
|
} from 'payload/types';
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ keywords: row, fields, config, configuration, documentation, Content Management
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ Set to `true` if you'd like this field to be sortable within the Admin UI using
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Each tab has its own required `label` and `fields` array. You can also optionall
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ Set this property to a string that will be used for browser autocomplete.
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ Set this property to a string that will be used for browser autocomplete.
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ With this field, you can also inject custom `Cell` components that appear as add
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleCollection: CollectionConfig = {
|
export const ExampleCollection: CollectionConfig = {
|
||||||
slug: 'example-collection',
|
slug: 'example-collection',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ Everything that can be done to a Collection via the REST or Local API can be don
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const PublicUser: CollectionConfig = {
|
export const PublicUser: CollectionConfig = {
|
||||||
slug: 'public-users',
|
slug: 'public-users',
|
||||||
auth: true, // Auth is enabled
|
auth: true, // Auth is enabled
|
||||||
fields: [
|
fields: [
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ All collection Hook properties accept arrays of synchronous or asynchronous func
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const ExampleHooks: CollectionConfig = {
|
export const ExampleHooks: CollectionConfig = {
|
||||||
slug: 'example-hooks',
|
slug: 'example-hooks',
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'name', type: 'text'},
|
{ name: 'name', type: 'text'},
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ For example, say you have a collection as follows:
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Post: CollectionConfig = {
|
export const Post: CollectionConfig = {
|
||||||
slug: 'posts',
|
slug: 'posts',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ Example:
|
|||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
// a collection of 'orders' with an additional route for tracking details, reachable at /api/orders/:id/tracking
|
// a collection of 'orders' with an additional route for tracking details, reachable at /api/orders/:id/tracking
|
||||||
const Orders: CollectionConfig = {
|
export const Orders: CollectionConfig = {
|
||||||
slug: 'orders',
|
slug: 'orders',
|
||||||
fields: [ /* ... */ ],
|
fields: [ /* ... */ ],
|
||||||
// highlight-start
|
// highlight-start
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ _An asterisk denotes that a property above is required._
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Media: CollectionConfig = {
|
export const Media: CollectionConfig = {
|
||||||
slug: 'media',
|
slug: 'media',
|
||||||
upload: {
|
upload: {
|
||||||
staticURL: '/media',
|
staticURL: '/media',
|
||||||
@@ -165,7 +165,7 @@ You can specify how Payload retrieves admin thumbnails for your upload-enabled C
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Media: CollectionConfig = {
|
export const Media: CollectionConfig = {
|
||||||
slug: 'media',
|
slug: 'media',
|
||||||
upload: {
|
upload: {
|
||||||
staticURL: '/media',
|
staticURL: '/media',
|
||||||
@@ -200,7 +200,7 @@ Some example values are: `image/*`, `audio/*`, `video/*`, `image/png`, `applicat
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Media: CollectionConfig = {
|
export const Media: CollectionConfig = {
|
||||||
slug: 'media',
|
slug: 'media',
|
||||||
upload: {
|
upload: {
|
||||||
staticURL: '/media',
|
staticURL: '/media',
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Collections and Globals both support the same options for configuring autosave.
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Pages: CollectionConfig = {
|
export const Pages: CollectionConfig = {
|
||||||
slug: 'pages',
|
slug: 'pages',
|
||||||
access: {
|
access: {
|
||||||
read: ({ req }) => {
|
read: ({ req }) => {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ Here is an example that utilizes the `_status` field to require a user to be log
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Pages: CollectionConfig = {
|
export const Pages: CollectionConfig = {
|
||||||
slug: 'pages',
|
slug: 'pages',
|
||||||
access: {
|
access: {
|
||||||
read: ({ req }) => {
|
read: ({ req }) => {
|
||||||
@@ -119,7 +119,7 @@ Here is an example for how to write an access control function that grants acces
|
|||||||
```ts
|
```ts
|
||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
|
||||||
const Pages: CollectionConfig = {
|
export const Pages: CollectionConfig = {
|
||||||
slug: 'pages',
|
slug: 'pages',
|
||||||
access: {
|
access: {
|
||||||
read: ({ req }) => {
|
read: ({ req }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user