payload 1.10.5 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/styles.css +1 -1
- package/dist/admin/components/elements/Button/index.scss +4 -0
- package/dist/admin/components/elements/ReactSelect/index.js +2 -2
- package/dist/admin/components/elements/ReactSelect/index.js.map +1 -1
- package/dist/admin/components/elements/ReactSelect/types.d.ts +4 -0
- package/dist/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.js +4 -2
- package/dist/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.js.map +1 -1
- package/dist/admin/components/forms/Label/index.js +1 -0
- package/dist/admin/components/forms/Label/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/Blocks/index.js +19 -16
- package/dist/admin/components/forms/field-types/Blocks/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/Relationship/index.js +1 -1
- package/dist/admin/components/forms/field-types/Relationship/select-components/MultiValueLabel/index.js +4 -2
- package/dist/admin/components/forms/field-types/Relationship/select-components/MultiValueLabel/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/RichText/RichText.js +1 -1
- package/dist/admin/components/forms/field-types/RichText/RichText.js.map +1 -1
- package/dist/auth/operations/local/forgotPassword.js +1 -1
- package/dist/auth/operations/local/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/login.js +1 -1
- package/dist/auth/operations/local/login.js.map +1 -1
- package/dist/auth/operations/local/resetPassword.js +1 -1
- package/dist/auth/operations/local/resetPassword.js.map +1 -1
- package/dist/auth/operations/local/unlock.js +1 -1
- package/dist/auth/operations/local/unlock.js.map +1 -1
- package/dist/auth/operations/local/verifyEmail.js +1 -1
- package/dist/auth/operations/local/verifyEmail.js.map +1 -1
- package/dist/auth/types.d.ts +10 -3
- package/dist/auth/types.js.map +1 -1
- package/dist/collections/buildEndpoints.js +83 -106
- package/dist/collections/buildEndpoints.js.map +1 -1
- package/dist/collections/operations/local/create.js +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.js +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/find.js +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.js +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.js +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.js +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/config/types.d.ts +1 -1
- package/dist/errors/APIError.d.ts +9 -9
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/QueryError.d.ts +3 -1
- package/dist/errors/QueryError.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +4 -1
- package/dist/errors/ValidationError.js +3 -1
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/express/responses/formatError.d.ts +3 -1
- package/dist/fields/hooks/afterRead/promise.js +47 -0
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/globals/buildEndpoints.js +25 -33
- package/dist/globals/buildEndpoints.js.map +1 -1
- package/dist/graphql/schema/withOperators.js +3 -1
- package/dist/graphql/schema/withOperators.js.map +1 -1
- package/dist/utilities/getEntityPolicies.js +26 -1
- package/dist/utilities/getEntityPolicies.js.map +1 -1
- package/docs/admin/components.mdx +17 -20
- package/docs/admin/overview.mdx +4 -4
- package/docs/authentication/overview.mdx +5 -0
- package/docs/cloud/configuration.mdx +62 -0
- package/docs/cloud/creating-a-project.mdx +53 -0
- package/docs/cloud/projects.mdx +110 -0
- package/docs/cloud/teams.mdx +35 -0
- package/docs/configuration/i18n.mdx +30 -24
- package/docs/configuration/overview.mdx +2 -3
- package/docs/email/overview.mdx +44 -37
- package/docs/fields/relationship.mdx +4 -4
- package/docs/fields/upload.mdx +30 -30
- package/docs/graphql/overview.mdx +2 -10
- package/docs/production/deployment.mdx +10 -9
- package/docs/queries/overview.mdx +2 -2
- package/package.json +1 -1
|
@@ -11,44 +11,49 @@ Not only does Payload support managing localized content, it also has internatio
|
|
|
11
11
|
While Payload's built-in features come translated, you may want to also translate parts of your project's configuration too. This is possible in places like collections and globals labels and groups, field labels, descriptions and input placeholder text. The admin UI will display all the correct translations you provide based on the user's language.
|
|
12
12
|
|
|
13
13
|
Here is an example of a simple collection supporting both English and Spanish editors:
|
|
14
|
+
|
|
14
15
|
```ts
|
|
15
|
-
import { CollectionConfig } from
|
|
16
|
+
import { CollectionConfig } from "payload/types";
|
|
16
17
|
|
|
17
18
|
export const Articles: CollectionConfig = {
|
|
18
|
-
slug:
|
|
19
|
+
slug: "articles",
|
|
19
20
|
labels: {
|
|
20
21
|
singular: {
|
|
21
|
-
en:
|
|
22
|
+
en: "Article",
|
|
23
|
+
es: "Artículo",
|
|
22
24
|
},
|
|
23
25
|
plural: {
|
|
24
|
-
en:
|
|
26
|
+
en: "Articles",
|
|
27
|
+
es: "Artículos",
|
|
25
28
|
},
|
|
26
29
|
},
|
|
27
30
|
admin: {
|
|
28
|
-
group: { en:
|
|
31
|
+
group: { en: "Content", es: "Contenido" },
|
|
29
32
|
},
|
|
30
33
|
fields: [
|
|
31
34
|
{
|
|
32
|
-
name:
|
|
33
|
-
type:
|
|
35
|
+
name: "title",
|
|
36
|
+
type: "text",
|
|
34
37
|
label: {
|
|
35
|
-
en:
|
|
38
|
+
en: "Title",
|
|
39
|
+
es: "Título",
|
|
36
40
|
},
|
|
37
41
|
admin: {
|
|
38
|
-
placeholder: { en:
|
|
39
|
-
}
|
|
42
|
+
placeholder: { en: "Enter title", es: "Introduce el título" },
|
|
43
|
+
},
|
|
40
44
|
},
|
|
41
45
|
{
|
|
42
|
-
name:
|
|
43
|
-
type:
|
|
44
|
-
options: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
name: "type",
|
|
47
|
+
type: "radio",
|
|
48
|
+
options: [
|
|
49
|
+
{
|
|
50
|
+
value: "news",
|
|
51
|
+
label: { en: "News", es: "Noticias" },
|
|
52
|
+
}, // etc...
|
|
48
53
|
],
|
|
49
54
|
},
|
|
50
55
|
],
|
|
51
|
-
}
|
|
56
|
+
};
|
|
52
57
|
```
|
|
53
58
|
|
|
54
59
|
### Admin UI
|
|
@@ -57,8 +62,8 @@ The Payload admin panel reads the language settings of a user's browser and disp
|
|
|
57
62
|
After a user logs in, they can change their language selection in the `/account` view.
|
|
58
63
|
|
|
59
64
|
<Banner>
|
|
60
|
-
<strong>Note:</strong><br/>
|
|
61
|
-
If there is a language that Payload does not yet support, we accept code
|
|
65
|
+
<strong>Note:</strong><br />
|
|
66
|
+
If there is a language that Payload does not yet support, we accept code [contributions](https://github.com/payloadcms/payload/blob/master/contributing.md).
|
|
62
67
|
</Banner>
|
|
63
68
|
|
|
64
69
|
### Node Express
|
|
@@ -76,21 +81,22 @@ In your Payload config, you can add translations and customize the settings in `
|
|
|
76
81
|
**Example Payload config extending i18n:**
|
|
77
82
|
|
|
78
83
|
```ts
|
|
79
|
-
import { buildConfig } from
|
|
84
|
+
import { buildConfig } from "payload/config";
|
|
80
85
|
|
|
81
86
|
export default buildConfig({
|
|
82
87
|
//...
|
|
83
88
|
i18n: {
|
|
84
|
-
fallbackLng:
|
|
89
|
+
fallbackLng: "en", // default
|
|
85
90
|
debug: false, // default
|
|
86
91
|
resources: {
|
|
87
92
|
en: {
|
|
88
|
-
custom: {
|
|
89
|
-
|
|
93
|
+
custom: {
|
|
94
|
+
// namespace can be anything you want
|
|
95
|
+
key1: "Translation with {{variable}}", // translation
|
|
90
96
|
},
|
|
91
97
|
// override existing translation keys
|
|
92
98
|
general: {
|
|
93
|
-
dashboard:
|
|
99
|
+
dashboard: "Home",
|
|
94
100
|
},
|
|
95
101
|
},
|
|
96
102
|
},
|
|
@@ -122,9 +122,8 @@ project-name
|
|
|
122
122
|
<br />
|
|
123
123
|
If you use an environment variable to configure any properties that are
|
|
124
124
|
required for the Admin panel to function (ex. serverURL or any routes), you
|
|
125
|
-
need to make sure that your Admin panel code can access it.
|
|
126
|
-
|
|
127
|
-
info.
|
|
125
|
+
need to make sure that your Admin panel code can access it. [Click
|
|
126
|
+
here](/docs/admin/webpack#admin-environment-vars) for more info.
|
|
128
127
|
</Banner>
|
|
129
128
|
|
|
130
129
|
### Customizing & overriding the config location
|
package/docs/email/overview.mdx
CHANGED
|
@@ -25,21 +25,22 @@ in the `email` property object of your payload init call. Payload will make use
|
|
|
25
25
|
|
|
26
26
|
The following options are configurable in the `email` property object as part of the options object when calling payload.init().
|
|
27
27
|
|
|
28
|
-
| Option
|
|
29
|
-
|
|
|
30
|
-
| **`fromName`**
|
|
31
|
-
| **`fromAddress`**
|
|
32
|
-
| **`transport`**
|
|
33
|
-
| **`transportOptions`**
|
|
34
|
-
| **`logMockCredentials`**
|
|
28
|
+
| Option | Description |
|
|
29
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
30
|
+
| **`fromName`** \* | The name part of the From field that will be seen on the delivered email |
|
|
31
|
+
| **`fromAddress`** \* | The email address part of the From field that will be used when delivering email |
|
|
32
|
+
| **`transport`** | The NodeMailer transport object for when you want to do it yourself, not needed when transportOptions is set |
|
|
33
|
+
| **`transportOptions`** | An object that configures the transporter that Payload will create. For all the available options see the [NodeMailer documentation](https://nodemailer.com/smtp/) or see the examples below |
|
|
34
|
+
| **`logMockCredentials`** | If set to true and no transport/transportOptions, ethereal credentials will be logged to console on startup |
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
_\* An asterisk denotes that a property is required._
|
|
37
37
|
|
|
38
38
|
### Use SMTP
|
|
39
39
|
|
|
40
40
|
Simple Mail Transfer Protocol, also known as SMTP can be passed in using the `transportOptions` object on the `email` options.
|
|
41
41
|
|
|
42
42
|
**Example email part using SMTP:**
|
|
43
|
+
|
|
43
44
|
```ts
|
|
44
45
|
payload.init({
|
|
45
46
|
email: {
|
|
@@ -47,24 +48,24 @@ payload.init({
|
|
|
47
48
|
host: process.env.SMTP_HOST,
|
|
48
49
|
auth: {
|
|
49
50
|
user: process.env.SMTP_USER,
|
|
50
|
-
pass: process.env.SMTP_PASS
|
|
51
|
+
pass: process.env.SMTP_PASS,
|
|
51
52
|
},
|
|
52
53
|
port: 587,
|
|
53
54
|
secure: true, // use TLS
|
|
54
55
|
tls: {
|
|
55
56
|
// do not fail on invalid certs
|
|
56
|
-
rejectUnauthorized: false
|
|
57
|
-
}
|
|
57
|
+
rejectUnauthorized: false,
|
|
58
58
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
},
|
|
60
|
+
fromName: "hello",
|
|
61
|
+
fromAddress: "hello@example.com",
|
|
62
|
+
},
|
|
62
63
|
// ...
|
|
63
|
-
})
|
|
64
|
+
});
|
|
64
65
|
```
|
|
65
66
|
|
|
66
67
|
<Banner type="warning">
|
|
67
|
-
It is best practice to avoid saving credentials or API keys directly in your code, use
|
|
68
|
+
It is best practice to avoid saving credentials or API keys directly in your code, use [environment variables](/docs/configuration/overview#using-environment-variables-in-your-config).
|
|
68
69
|
</Banner>
|
|
69
70
|
|
|
70
71
|
### Use an email service
|
|
@@ -72,57 +73,62 @@ payload.init({
|
|
|
72
73
|
Many third party mail providers are available and offer benefits beyond basic SMTP. As an example your payload init could look this if you wanted to use SendGrid.com though the same approach would work for any other [NodeMailer transports](https://nodemailer.com/transports/) shown here or provided by another third party.
|
|
73
74
|
|
|
74
75
|
```ts
|
|
75
|
-
import payload from
|
|
76
|
-
import nodemailerSendgrid from
|
|
76
|
+
import payload from "payload";
|
|
77
|
+
import nodemailerSendgrid from "nodemailer-sendgrid";
|
|
77
78
|
|
|
78
79
|
const sendGridAPIKey = process.env.SENDGRID_API_KEY;
|
|
79
80
|
|
|
80
81
|
payload.init({
|
|
81
|
-
...sendGridAPIKey
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
...(sendGridAPIKey
|
|
83
|
+
? {
|
|
84
|
+
email: {
|
|
85
|
+
transportOptions: nodemailerSendgrid({
|
|
86
|
+
apiKey: sendGridAPIKey,
|
|
87
|
+
}),
|
|
88
|
+
fromName: "Admin",
|
|
89
|
+
fromAddress: "admin@example.com",
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
: {}),
|
|
90
93
|
});
|
|
91
94
|
```
|
|
92
95
|
|
|
93
96
|
### Use a custom NodeMailer transport
|
|
97
|
+
|
|
94
98
|
To take full control of the mail transport you may wish to use `nodemailer.createTransport()` on your server and provide it to Payload init.
|
|
95
99
|
|
|
96
100
|
```ts
|
|
97
|
-
import payload from
|
|
98
|
-
import nodemailer from
|
|
101
|
+
import payload from "payload";
|
|
102
|
+
import nodemailer from "nodemailer";
|
|
99
103
|
|
|
100
|
-
const payload = require(
|
|
101
|
-
const nodemailer = require(
|
|
104
|
+
const payload = require("payload");
|
|
105
|
+
const nodemailer = require("nodemailer");
|
|
102
106
|
|
|
103
107
|
const transport = await nodemailer.createTransport({
|
|
104
108
|
host: process.env.SMTP_HOST,
|
|
105
109
|
port: 587,
|
|
106
110
|
auth: {
|
|
107
111
|
user: process.env.SMTP_USER,
|
|
108
|
-
pass: process.env.SMTP_PASS
|
|
112
|
+
pass: process.env.SMTP_PASS,
|
|
109
113
|
},
|
|
110
114
|
});
|
|
111
115
|
|
|
112
116
|
payload.init({
|
|
113
117
|
email: {
|
|
114
|
-
fromName:
|
|
115
|
-
fromAddress:
|
|
116
|
-
transport
|
|
118
|
+
fromName: "Admin",
|
|
119
|
+
fromAddress: "admin@example.com",
|
|
120
|
+
transport,
|
|
117
121
|
},
|
|
118
122
|
// ...
|
|
119
123
|
});
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
### Sending Mail
|
|
127
|
+
|
|
123
128
|
With a working transport you can call it anywhere you have access to payload by calling `payload.sendEmail(message)`. The `message` will contain the `to`, `subject` and `email` or `text` for the email being sent. To see all available message configuration options see [NodeMailer](https://nodemailer.com/message).
|
|
124
129
|
|
|
125
130
|
### Mock transport
|
|
131
|
+
|
|
126
132
|
By default, Payload uses a mock implementation that only sends mail to the [ethereal](https://ethereal.email) capture service that will never reach a user's inbox. While in development you may wish to make use of the captured messages which is why the payload output during server output helpfully logs this out on the server console.
|
|
127
133
|
|
|
128
134
|
To see ethereal credentials, add `logMockCredentials: true` to the email options. This will cause them to be logged to console on startup.
|
|
@@ -130,8 +136,8 @@ To see ethereal credentials, add `logMockCredentials: true` to the email options
|
|
|
130
136
|
```ts
|
|
131
137
|
payload.init({
|
|
132
138
|
email: {
|
|
133
|
-
fromName:
|
|
134
|
-
fromAddress:
|
|
139
|
+
fromName: "Admin",
|
|
140
|
+
fromAddress: "admin@example.com",
|
|
135
141
|
logMockCredentials: true, // Optional
|
|
136
142
|
},
|
|
137
143
|
// ...
|
|
@@ -139,6 +145,7 @@ payload.init({
|
|
|
139
145
|
```
|
|
140
146
|
|
|
141
147
|
**Console output when starting payload with a mock email instance and logMockCredentials: true**
|
|
148
|
+
|
|
142
149
|
```
|
|
143
150
|
[06:37:21] INFO (payload): Starting Payload...
|
|
144
151
|
[06:37:22] INFO (payload): Payload Demo Initialized
|
|
@@ -25,8 +25,8 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
|
|
|
25
25
|
| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. |
|
|
26
26
|
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
|
|
27
27
|
| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. |
|
|
28
|
-
| **`minRows`**
|
|
29
|
-
| **`maxRows`**
|
|
28
|
+
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. |
|
|
29
|
+
| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. |
|
|
30
30
|
| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
|
|
31
31
|
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
|
|
32
32
|
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
|
|
@@ -47,8 +47,8 @@ _\* An asterisk denotes that a property is required._
|
|
|
47
47
|
<Banner type="success">
|
|
48
48
|
<strong>Tip:</strong>
|
|
49
49
|
<br />
|
|
50
|
-
The
|
|
51
|
-
|
|
50
|
+
The [Depth](/docs/getting-started/concepts#depth) parameter can be used to
|
|
51
|
+
automatically populate related documents that are returned by the API.
|
|
52
52
|
</Banner>
|
|
53
53
|
|
|
54
54
|
### Admin config
|
package/docs/fields/upload.mdx
CHANGED
|
@@ -6,13 +6,13 @@ desc: Upload fields will allow a file to be uploaded, only from a collection sup
|
|
|
6
6
|
keywords: upload, images media, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
<Banner
|
|
9
|
+
<Banner>
|
|
10
10
|
The Upload field allows for the selection of a Document from a collection supporting Uploads, and formats the selection as a thumbnail in the Admin panel.
|
|
11
11
|
</Banner>
|
|
12
12
|
|
|
13
13
|
<Banner type="warning">
|
|
14
|
-
<strong>Important:</strong><br/>
|
|
15
|
-
To use this field, you need to have a Collection configured to allow Uploads. For more information,
|
|
14
|
+
<strong>Important:</strong><br />
|
|
15
|
+
To use this field, you need to have a Collection configured to allow Uploads. For more information, [click here](/docs/upload/overview) to read about how to enable Uploads on a collection by collection basis.
|
|
16
16
|
</Banner>
|
|
17
17
|
|
|
18
18
|
**Example uses:**
|
|
@@ -23,10 +23,10 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
|
|
|
23
23
|
|
|
24
24
|
### Config
|
|
25
25
|
|
|
26
|
-
| Option
|
|
27
|
-
|
|
|
28
|
-
| **`name`**
|
|
29
|
-
| **`*relationTo`**
|
|
26
|
+
| Option | Description |
|
|
27
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
|
|
29
|
+
| **`*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> |
|
|
30
30
|
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). |
|
|
31
31
|
| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
|
|
32
32
|
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
|
|
@@ -41,28 +41,28 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
|
|
|
41
41
|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
|
|
42
42
|
| **`required`** | Require this field to have a value. |
|
|
43
43
|
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
|
|
44
|
-
| **`custom`** | Extension point for adding custom data (e.g. for plugins)
|
|
44
|
+
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
_\* An asterisk denotes that a property is required._
|
|
47
47
|
|
|
48
48
|
### Example
|
|
49
49
|
|
|
50
50
|
`collections/ExampleCollection.ts`
|
|
51
|
+
|
|
51
52
|
```ts
|
|
52
|
-
import { CollectionConfig } from
|
|
53
|
+
import { CollectionConfig } from "payload/types";
|
|
53
54
|
|
|
54
55
|
export const ExampleCollection: CollectionConfig = {
|
|
55
|
-
slug:
|
|
56
|
+
slug: "example-collection",
|
|
56
57
|
fields: [
|
|
57
58
|
{
|
|
58
|
-
name:
|
|
59
|
-
type:
|
|
60
|
-
relationTo:
|
|
59
|
+
name: "backgroundImage", // required
|
|
60
|
+
type: "upload", // required
|
|
61
|
+
relationTo: "media", // required
|
|
61
62
|
required: true,
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
### Filtering upload options
|
|
@@ -71,23 +71,23 @@ Options can be dynamically limited by supplying a [query constraint](/docs/queri
|
|
|
71
71
|
|
|
72
72
|
The `filterOptions` property can either be a `Where` query directly, or a function that returns one. When using a function, it will be called with an argument object with the following properties:
|
|
73
73
|
|
|
74
|
-
| Property | Description
|
|
75
|
-
| ------------- |
|
|
76
|
-
| `relationTo`
|
|
77
|
-
| `data`
|
|
78
|
-
| `siblingData`
|
|
79
|
-
| `id`
|
|
80
|
-
| `user`
|
|
74
|
+
| Property | Description |
|
|
75
|
+
| ------------- | ------------------------------------------------------------------------------------ |
|
|
76
|
+
| `relationTo` | The `relationTo` to filter against (as defined on the field) |
|
|
77
|
+
| `data` | An object of the full collection or global document currently being edited |
|
|
78
|
+
| `siblingData` | An object of the document data limited to fields within the same parent to the field |
|
|
79
|
+
| `id` | The value of the collection `id`, will be `undefined` on create request |
|
|
80
|
+
| `user` | The currently authenticated user object |
|
|
81
81
|
|
|
82
82
|
**Example:**
|
|
83
83
|
|
|
84
84
|
```ts
|
|
85
85
|
const uploadField = {
|
|
86
|
-
name:
|
|
87
|
-
type:
|
|
88
|
-
relationTo:
|
|
86
|
+
name: "image",
|
|
87
|
+
type: "upload",
|
|
88
|
+
relationTo: "media",
|
|
89
89
|
filterOptions: {
|
|
90
|
-
mimeType: { contains:
|
|
90
|
+
mimeType: { contains: "image" },
|
|
91
91
|
},
|
|
92
92
|
};
|
|
93
93
|
```
|
|
@@ -95,6 +95,6 @@ const uploadField = {
|
|
|
95
95
|
You can learn more about writing queries [here](/docs/queries/overview).
|
|
96
96
|
|
|
97
97
|
<Banner type="warning">
|
|
98
|
-
<strong>Note:</strong><br/>
|
|
98
|
+
<strong>Note:</strong><br />
|
|
99
99
|
When an upload field has both <strong>filterOptions</strong> and a custom <strong>validate</strong> function, the api will not validate <strong>filterOptions</strong> unless you call the default upload field validation function imported from <strong>payload/fields/validations</strong> in your validate function.
|
|
100
100
|
</Banner>
|
|
@@ -115,16 +115,8 @@ GraphQL Playground is enabled by default for development purposes, but disabled
|
|
|
115
115
|
You can even log in using the `login[collection-singular-label-here]` mutation to use the Playground as an authenticated user.
|
|
116
116
|
|
|
117
117
|
<Banner type="success">
|
|
118
|
-
<strong>Tip:</strong
|
|
119
|
-
|
|
120
|
-
To see more regarding how the above queries and mutations are used, visit your
|
|
121
|
-
GraphQL playground (by default at{" "}
|
|
122
|
-
<a href="http://localhost:3000/api/graphql-playground">
|
|
123
|
-
(http://localhost:3000/api/graphql-playground
|
|
124
|
-
</a>
|
|
125
|
-
) while your server is running. There, you can use the "Schema" and "Docs"
|
|
126
|
-
buttons on the right to see a ton of detail about how GraphQL operates within
|
|
127
|
-
Payload.
|
|
118
|
+
<strong>Tip:</strong><br />
|
|
119
|
+
To see more regarding how the above queries and mutations are used, visit your GraphQL playground (by default at [http://localhost:3000/api/graphql-playground](http://localhost:3000/api/graphql-playground)) while your server is running. There, you can use the "Schema" and "Docs" buttons on the right to see a ton of detail about how GraphQL operates within Payload.
|
|
128
120
|
</Banner>
|
|
129
121
|
|
|
130
122
|
## Query complexity limits
|
|
@@ -43,6 +43,7 @@ Because _**you**_ are in complete control of who can do what with your data, you
|
|
|
43
43
|
Before running in Production, you need to have built a production-ready copy of the Payload Admin panel. To do this, Payload provides the `build` NPM script. You can use it by adding a `script` to your `package.json` file like this:
|
|
44
44
|
|
|
45
45
|
`package.json`:
|
|
46
|
+
|
|
46
47
|
```json
|
|
47
48
|
{
|
|
48
49
|
"name": "project-name-here",
|
|
@@ -51,7 +52,8 @@ Before running in Production, you need to have built a production-ready copy of
|
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
54
|
// your dependencies
|
|
54
|
-
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
Then, to build Payload, you would run `npm run build` in your project folder. A production-ready Admin bundle will be created in the `build` directory.
|
|
@@ -81,16 +83,16 @@ If you are using a [persistent filesystem-based cloud host](#persistent-vs-ephem
|
|
|
81
83
|
Alternatively, you can rely on a third-party MongoDB host such as [MongoDB Atlas](https://www.mongodb.com/). With Atlas or a similar cloud provider, you can trust them to take care of your database's availability, security, redundancy, and backups.
|
|
82
84
|
|
|
83
85
|
<Banner type="warning">
|
|
84
|
-
<strong>Note:</strong
|
|
85
|
-
|
|
86
|
-
If versions are enabled and a collection has many documents you may need a minimum of an m10 mongoDB atlas cluster if you reach a sorting `exceeded memory limit` error to view a collection list in the admin UI. The limitations of the m2 and m5 tier clusters are here:
|
|
87
|
-
<a href="https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/?_ga=2.176267877.1329169847.1677683154-860992573.1647438381#operational-limitations">Atlas M0 (Free Cluster), M2, and M5 Limitations</a>
|
|
86
|
+
<strong>Note:</strong><br />
|
|
87
|
+
If versions are enabled and a collection has many documents you may need a minimum of an m10 mongoDB atlas cluster if you reach a sorting `exceeded memory limit` error to view a collection list in the admin UI. The limitations of the m2 and m5 tier clusters are here: [Atlas M0 (Free Cluster), M2, and M5 Limitations](https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/?_ga=2.176267877.1329169847.1677683154-860992573.1647438381#operational-limitations).
|
|
88
88
|
</Banner>
|
|
89
89
|
|
|
90
90
|
##### DocumentDB
|
|
91
|
+
|
|
91
92
|
When using AWS DocumentDB, you will need to configure connection options for authentication in the `mongoOptions` passed to `payload.init`. You also need to set `mongoOptions.useFacet` to `false` to disable use of the unsupported `$facet` aggregation.
|
|
92
93
|
|
|
93
94
|
##### CosmosDB
|
|
95
|
+
|
|
94
96
|
When using Azure Cosmos DB, an index is needed for any field you may want to sort on. To add the sort index for all fields that may be sorted in the admin UI use the <a href="/docs/configuration/overview">indexSortableFields</a> configuration option.
|
|
95
97
|
|
|
96
98
|
## File storage
|
|
@@ -116,7 +118,7 @@ Alternatively, persistent filesystems will never delete your files and can be tr
|
|
|
116
118
|
- Many other more traditional web hosts
|
|
117
119
|
|
|
118
120
|
<Banner type="error">
|
|
119
|
-
<strong>Warning:</strong><br/>
|
|
121
|
+
<strong>Warning:</strong><br />
|
|
120
122
|
If you rely on Payload's <strong>Upload</strong> 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.
|
|
121
123
|
</Banner>
|
|
122
124
|
|
|
@@ -124,7 +126,7 @@ Alternatively, persistent filesystems will never delete your files and can be tr
|
|
|
124
126
|
|
|
125
127
|
If you don't use Payload's `upload` functionality, you can go ahead and use Heroku or similar platform easily. Everything will work exactly as you want it to.
|
|
126
128
|
|
|
127
|
-
But, if you do, and you still want to use an ephemeral filesystem provider, you can write a hook-based solution to
|
|
129
|
+
But, if you do, and you still want to use an ephemeral filesystem provider, you can write a hook-based solution to _copy_ the files your users upload to a more permanent storage solution like Amazon S3 or DigitalOcean Spaces.
|
|
128
130
|
|
|
129
131
|
**To automatically send uploaded files to S3 or similar, you could:**
|
|
130
132
|
|
|
@@ -182,10 +184,9 @@ CMD ["node", "dist/server.js"]
|
|
|
182
184
|
Here is an example of a docker-compose.yml file that can be used for development
|
|
183
185
|
|
|
184
186
|
```yml
|
|
185
|
-
version:
|
|
187
|
+
version: "3"
|
|
186
188
|
|
|
187
189
|
services:
|
|
188
|
-
|
|
189
190
|
payload:
|
|
190
191
|
image: node:18-alpine
|
|
191
192
|
ports:
|
|
@@ -9,7 +9,7 @@ keywords: query, documents, overview, documentation, Content Management System,
|
|
|
9
9
|
Payload provides an extremely granular querying language through all APIs. Each API takes the same syntax and fully supports all options.
|
|
10
10
|
|
|
11
11
|
<Banner>
|
|
12
|
-
<strong>Here, "querying" relates to filtering or searching through documents within a Collection.</strong> You can build queries to pass to Find operations as well as to
|
|
12
|
+
<strong>Here, "querying" relates to filtering or searching through documents within a Collection.</strong> You can build queries to pass to Find operations as well as to [restrict which documents certain users can access](/docs/access-control/overview) via access control functions.
|
|
13
13
|
</Banner>
|
|
14
14
|
|
|
15
15
|
### Simple queries
|
|
@@ -67,7 +67,7 @@ The above example demonstrates a simple query but you can get much more complex.
|
|
|
67
67
|
| `near` | For distance related to a [point field](/docs/fields/point) comma separated as `<longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>`. |
|
|
68
68
|
|
|
69
69
|
<Banner type="success">
|
|
70
|
-
<strong>Tip</strong>:<br/>
|
|
70
|
+
<strong>Tip</strong>:<br />
|
|
71
71
|
If you know your users will be querying on certain fields a lot, you can add <strong>index: true</strong> to a field's config which will speed up searches using that field immensely.
|
|
72
72
|
</Banner>
|
|
73
73
|
|