payload 1.6.13 → 1.6.15
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/dist/admin/components/elements/WhereBuilder/field-types.js +8 -8
- package/dist/admin/components/elements/WhereBuilder/field-types.js.map +1 -1
- package/dist/admin/components/elements/WhereBuilder/index.js +4 -0
- package/dist/admin/components/elements/WhereBuilder/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/Code/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/RichText/elements/link/LinkDrawer/index.js +5 -13
- package/dist/admin/components/forms/field-types/RichText/elements/link/LinkDrawer/index.js.map +1 -1
- package/dist/admin/components/forms/withCondition/index.js +1 -0
- package/dist/admin/components/forms/withCondition/index.js.map +1 -1
- package/dist/admin/components/utilities/I18n/index.js +2 -1
- package/dist/admin/components/utilities/I18n/index.js.map +1 -1
- package/dist/admin/components/views/ResetPassword/index.js +5 -0
- package/dist/admin/components/views/ResetPassword/index.js.map +1 -1
- package/dist/admin/components/views/collections/List/index.js +2 -2
- package/dist/admin/components/views/collections/List/index.js.map +1 -1
- package/dist/admin/utilities/getSupportedMonacoLocale.d.ts +1 -0
- package/dist/admin/utilities/getSupportedMonacoLocale.js +19 -0
- package/dist/admin/utilities/getSupportedMonacoLocale.js.map +1 -0
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts +1 -1
- package/dist/auth/operations/resetPassword.js +3 -0
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/strategies/apiKey.js +1 -0
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/types.d.ts +1 -0
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/index.js +16 -4
- package/dist/bin/index.js.map +1 -1
- package/dist/collections/config/types.d.ts +1 -1
- package/dist/collections/graphql/resolvers/create.d.ts +1 -1
- package/dist/collections/operations/create.d.ts +1 -1
- package/dist/collections/operations/find.d.ts +1 -0
- package/dist/collections/operations/find.js +2 -2
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +1 -1
- package/dist/collections/operations/local/find.d.ts +1 -0
- package/dist/collections/operations/local/find.js +2 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/config/types.d.ts +4 -1
- package/dist/fields/hooks/afterRead/promise.js +3 -3
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/mongoose/buildQuery.js +5 -4
- package/dist/mongoose/buildQuery.js.map +1 -1
- package/dist/mongoose/connect.d.ts +2 -2
- package/dist/mongoose/connect.js +1 -1
- package/dist/mongoose/connect.js.map +1 -1
- package/dist/payload.d.ts +1 -0
- package/dist/payload.js +1 -0
- package/dist/payload.js.map +1 -1
- package/dist/translations/cs.json +14 -0
- package/dist/translations/de.json +14 -0
- package/dist/translations/en.json +14 -0
- package/dist/translations/es.json +14 -0
- package/dist/translations/fr.json +14 -0
- package/dist/translations/hr.json +14 -0
- package/dist/translations/index.d.ts +280 -0
- package/dist/translations/it.json +14 -0
- package/dist/translations/ja.json +14 -0
- package/dist/translations/my.json +14 -0
- package/dist/translations/nb.json +14 -0
- package/dist/translations/nl.json +14 -0
- package/dist/translations/pl.json +14 -0
- package/dist/translations/pt.json +14 -0
- package/dist/translations/ru.json +14 -0
- package/dist/translations/sv.json +14 -0
- package/dist/translations/th.json +14 -0
- package/dist/translations/tr.json +14 -0
- package/dist/translations/ua.json +14 -0
- package/dist/translations/vi.json +14 -0
- package/dist/translations/zh.json +14 -0
- package/dist/utilities/entityToJSONSchema.js +11 -1
- package/dist/utilities/entityToJSONSchema.js.map +1 -1
- package/dist/versions/drafts/queryDrafts.d.ts +2 -1
- package/dist/versions/drafts/queryDrafts.js +2 -0
- package/dist/versions/drafts/queryDrafts.js.map +1 -1
- package/docs/admin/overview.mdx +1 -1
- package/docs/fields/code.mdx +1 -1
- package/docs/local-api/overview.mdx +147 -91
- package/docs/production/deployment.mdx +8 -5
- package/docs/upload/overview.mdx +2 -2
- package/package.json +3 -2
|
@@ -218,6 +218,20 @@
|
|
|
218
218
|
"users": "Những người dùng",
|
|
219
219
|
"welcome": "Xin chào"
|
|
220
220
|
},
|
|
221
|
+
"operators": {
|
|
222
|
+
"equals": "bằng",
|
|
223
|
+
"isNotEqualTo": "không bằng",
|
|
224
|
+
"isIn": "đang ở",
|
|
225
|
+
"isNotIn": "không có trong",
|
|
226
|
+
"exists": "tồn tại",
|
|
227
|
+
"isGreaterThan": "lớn hơn",
|
|
228
|
+
"isLessThan": "nhỏ hơn",
|
|
229
|
+
"isLessThanOrEqualTo": "nhỏ hơn hoặc bằng",
|
|
230
|
+
"isGreaterThanOrEqualTo": "lớn hơn hoặc bằng",
|
|
231
|
+
"near": "gần",
|
|
232
|
+
"isLike": "giống như",
|
|
233
|
+
"contains": "chứa"
|
|
234
|
+
},
|
|
221
235
|
"upload": {
|
|
222
236
|
"dragAndDropHere": "hoặc kéo và thả file vào đây",
|
|
223
237
|
"fileName": "Tên file",
|
|
@@ -226,6 +226,20 @@
|
|
|
226
226
|
"users": "用户",
|
|
227
227
|
"welcome": "欢迎"
|
|
228
228
|
},
|
|
229
|
+
"operators": {
|
|
230
|
+
"equals": "等于",
|
|
231
|
+
"isNotEqualTo": "不等于",
|
|
232
|
+
"isIn": "在",
|
|
233
|
+
"isNotIn": "不在",
|
|
234
|
+
"exists": "存在",
|
|
235
|
+
"isGreaterThan": "大于",
|
|
236
|
+
"isLessThan": "小于",
|
|
237
|
+
"isLessThanOrEqualTo": "小于或等于",
|
|
238
|
+
"isGreaterThanOrEqualTo": "大于等于",
|
|
239
|
+
"near": "附近",
|
|
240
|
+
"isLike": "就像",
|
|
241
|
+
"contains": "包含"
|
|
242
|
+
},
|
|
229
243
|
"upload": {
|
|
230
244
|
"dragAndDropHere": "或在这里拖放一个文件",
|
|
231
245
|
"fileName": "文件名",
|
|
@@ -52,7 +52,17 @@ function generateFieldTypes(config, fields) {
|
|
|
52
52
|
break;
|
|
53
53
|
}
|
|
54
54
|
case 'json': {
|
|
55
|
-
|
|
55
|
+
// https://www.rfc-editor.org/rfc/rfc7159#section-3
|
|
56
|
+
fieldSchema = {
|
|
57
|
+
oneOf: [
|
|
58
|
+
{ type: 'object' },
|
|
59
|
+
{ type: 'array' },
|
|
60
|
+
{ type: 'string' },
|
|
61
|
+
{ type: 'number' },
|
|
62
|
+
{ type: 'boolean' },
|
|
63
|
+
{ type: 'null' },
|
|
64
|
+
],
|
|
65
|
+
};
|
|
56
66
|
break;
|
|
57
67
|
}
|
|
58
68
|
case 'richText': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityToJSONSchema.js","sourceRoot":"","sources":["../../src/utilities/entityToJSONSchema.ts"],"names":[],"mappings":";;;;;;AACA,yCAAqC;AAErC,kDAAyG;AAGzG,sEAA8C;AAC9C,iDAAyC;AAGzC,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAE3D,MAAM,kBAAkB,GAAG,CAAC,KAAY,EAAE,EAAE;IAC1C,OAAO,IAAA,wBAAgB,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACrI,CAAC,CAAC;AAEF,SAAS,mBAAmB,CAAC,WAAwC,EAAE,IAAY;IACjF,MAAM,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACrF,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAEvG,IAAI,aAAa,IAAI,aAAa,CAAC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ACZ,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;KACJ;IAED,OAAO;QACL,KAAK;QACL,IAAI,EAAE,QAAQ;QACd,oBAAoB,EAAE,KAAK;QAC3B,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;KAC7C,CAAC;AACJ,CAAC;AAzCD,gDAyCC;AAED,SAAgB,oBAAoB,CAAC,MAAuB,EAAE,IAA+B;IAC3F,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;YAC5D,IAAI;YACJ;gBACE,IAAI,EAAE,iBAAiB,IAAI,EAAE;aAC9B;SACF,CAAC,CAAC;QACH,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;QAC9C,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC;AAZD,oDAYC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PaginateOptions } from 'mongoose';
|
|
1
2
|
import { AccessResult } from '../../config/types';
|
|
2
3
|
import { Where } from '../../types';
|
|
3
4
|
import { Payload } from '../../payload';
|
|
@@ -7,7 +8,7 @@ type Args = {
|
|
|
7
8
|
accessResult: AccessResult;
|
|
8
9
|
collection: Collection;
|
|
9
10
|
locale: string;
|
|
10
|
-
paginationOptions:
|
|
11
|
+
paginationOptions: PaginateOptions;
|
|
11
12
|
payload: Payload;
|
|
12
13
|
where: Where;
|
|
13
14
|
};
|
|
@@ -4,6 +4,7 @@ exports.queryDrafts = void 0;
|
|
|
4
4
|
const auth_1 = require("../../auth");
|
|
5
5
|
const appendVersionToQueryKey_1 = require("./appendVersionToQueryKey");
|
|
6
6
|
const queryDrafts = async ({ accessResult, collection, locale, payload, paginationOptions, where: incomingWhere, }) => {
|
|
7
|
+
var _a;
|
|
7
8
|
const VersionModel = payload.versions[collection.config.slug];
|
|
8
9
|
const where = (0, appendVersionToQueryKey_1.appendVersionToQueryKey)(incomingWhere || {});
|
|
9
10
|
const versionQueryToBuild = {
|
|
@@ -43,6 +44,7 @@ const queryDrafts = async ({ accessResult, collection, locale, payload, paginati
|
|
|
43
44
|
const result = await VersionModel.aggregatePaginate(aggregate, {
|
|
44
45
|
...paginationOptions,
|
|
45
46
|
sort: paginationSort,
|
|
47
|
+
useFacet: (_a = payload.mongoOptions) === null || _a === void 0 ? void 0 : _a.useFacet,
|
|
46
48
|
});
|
|
47
49
|
return {
|
|
48
50
|
...result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryDrafts.js","sourceRoot":"","sources":["../../../src/versions/drafts/queryDrafts.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"queryDrafts.js","sourceRoot":"","sources":["../../../src/versions/drafts/queryDrafts.ts"],"names":[],"mappings":";;;AAMA,qCAAkD;AAClD,uEAAoE;AAkB7D,MAAM,WAAW,GAAG,KAAK,EAAwB,EACtD,YAAY,EACZ,UAAU,EACV,MAAM,EACN,OAAO,EACP,iBAAiB,EACjB,KAAK,EAAE,aAAa,GACf,EAA6B,EAAE;;IACpC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAoB,CAAC;IAEjF,MAAM,KAAK,GAAG,IAAA,iDAAuB,EAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAE3D,MAAM,mBAAmB,GAAqB;QAC5C,KAAK,EAAE;YACL,GAAG,KAAK;YACR,GAAG,EAAE;gBACH,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,KAAI,EAAE;aACpB;SACF;KACF,CAAC;IAEF,IAAI,IAAA,2BAAoB,EAAC,YAAY,CAAC,EAAE;QACtC,MAAM,mBAAmB,GAA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AC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC9B,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,GAAG,GAAG,CAAC,OAAO;YACd,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;SACzB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC;AAlEW,QAAA,WAAW,eAkEtB"}
|
package/docs/admin/overview.mdx
CHANGED
|
@@ -25,7 +25,7 @@ _Screenshot of the Admin panel while editing a document from an example `AllFiel
|
|
|
25
25
|
All options for the Admin panel are defined in your base Payload config file.
|
|
26
26
|
|
|
27
27
|
| Option | Description |
|
|
28
|
-
| --------------------- |
|
|
28
|
+
| --------------------- | -------------------------------------------------------------------------------------------------- |
|
|
29
29
|
| `user` | The `slug` of a Collection that you want be used to log in to the Admin dashboard. [More](/docs/admin/overview#the-admin-user-collection) |
|
|
30
30
|
| `buildPath` | Specify an absolute path for where to store the built Admin panel bundle used in production. Defaults to `path.resolve(process.cwd(), 'build')`. |
|
|
31
31
|
| `meta` | Base meta data to use for the Admin panel. Included properties are `titleSuffix`, `ogImage`, and `favicon`. |
|
package/docs/fields/code.mdx
CHANGED
|
@@ -42,7 +42,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
|
|
|
42
42
|
| Option | Description |
|
|
43
43
|
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
44
44
|
| **`language`** | This property can be set to any language listed [here](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages). |
|
|
45
|
-
| **`editorOptions`** | Options that can be passed to the monaco editor, [view the full list](https://microsoft.github.io/monaco-editor/
|
|
45
|
+
| **`editorOptions`** | Options that can be passed to the monaco editor, [view the full list](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IDiffEditorConstructionOptions.html). |
|
|
46
46
|
|
|
47
47
|
### Example
|
|
48
48
|
|
|
@@ -9,8 +9,14 @@ keywords: local api, config, configuration, documentation, Content Management Sy
|
|
|
9
9
|
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.
|
|
10
10
|
|
|
11
11
|
<Banner type="success">
|
|
12
|
-
<strong>Tip:</strong
|
|
13
|
-
|
|
12
|
+
<strong>Tip:</strong>
|
|
13
|
+
<br />
|
|
14
|
+
The Local API is incredibly powerful when used with server-side rendering app
|
|
15
|
+
frameworks like NextJS. With other headless CMS, you need to request your data
|
|
16
|
+
from third-party servers which can add significant loading time to your
|
|
17
|
+
server-rendered pages. With Payload, you don't have to leave your server to
|
|
18
|
+
gather the data you need. It can be incredibly fast and is definitely a game
|
|
19
|
+
changer.
|
|
14
20
|
</Banner>
|
|
15
21
|
|
|
16
22
|
Here are some common examples of how you can use the Local API:
|
|
@@ -28,15 +34,16 @@ You can gain access to the currently running `payload` object via two ways:
|
|
|
28
34
|
You can import or require `payload` into your own files after it's been initialized, but you need to make sure that your `import` / `require` statements come **after** you call `payload.init()`—otherwise Payload won't have been initialized yet. That might be obvious. To us, it's usually not.
|
|
29
35
|
|
|
30
36
|
Example:
|
|
37
|
+
|
|
31
38
|
```ts
|
|
32
|
-
import payload from
|
|
33
|
-
import { CollectionAfterChangeHook } from
|
|
39
|
+
import payload from "payload";
|
|
40
|
+
import { CollectionAfterChangeHook } from "payload/types";
|
|
34
41
|
|
|
35
42
|
const afterChangeHook: CollectionAfterChangeHook = async () => {
|
|
36
43
|
const posts = await payload.find({
|
|
37
|
-
collection:
|
|
44
|
+
collection: "posts",
|
|
38
45
|
});
|
|
39
|
-
}
|
|
46
|
+
};
|
|
40
47
|
```
|
|
41
48
|
|
|
42
49
|
##### Accessing from the `req`
|
|
@@ -44,35 +51,42 @@ const afterChangeHook: CollectionAfterChangeHook = async () => {
|
|
|
44
51
|
Payload is available anywhere you have access to the Express `req` - including within your access control and hook functions.
|
|
45
52
|
|
|
46
53
|
Example:
|
|
54
|
+
|
|
47
55
|
```ts
|
|
48
|
-
const afterChangeHook: CollectionAfterChangeHook = async ({
|
|
56
|
+
const afterChangeHook: CollectionAfterChangeHook = async ({
|
|
57
|
+
req: { payload },
|
|
58
|
+
}) => {
|
|
49
59
|
const posts = await payload.find({
|
|
50
|
-
collection:
|
|
60
|
+
collection: "posts",
|
|
51
61
|
});
|
|
52
|
-
}
|
|
62
|
+
};
|
|
53
63
|
```
|
|
54
64
|
|
|
55
65
|
### Local options available
|
|
56
66
|
|
|
57
67
|
You can specify more options within the Local API vs. REST or GraphQL due to the server-only context that they are executed in.
|
|
58
68
|
|
|
59
|
-
| Local Option
|
|
60
|
-
|
|
|
61
|
-
| `collection`
|
|
62
|
-
| `data`
|
|
63
|
-
| `depth`
|
|
64
|
-
| `locale`
|
|
65
|
-
| `fallbackLocale`
|
|
66
|
-
| `overrideAccess`
|
|
67
|
-
| `user`
|
|
68
|
-
| `showHiddenFields`
|
|
69
|
-
| `
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
| Local Option | Description |
|
|
70
|
+
| ------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `collection` | Required for Collection operations. Specifies the Collection slug to operate against. |
|
|
72
|
+
| `data` | The data to use within the operation. Required for `create`, `update`. |
|
|
73
|
+
| `depth` | [Control auto-population](/docs/getting-started/concepts#depth) of nested relationship and upload fields. |
|
|
74
|
+
| `locale` | Specify [locale](/docs/configuration/localization) for any returned documents. |
|
|
75
|
+
| `fallbackLocale` | Specify a [fallback locale](/docs/configuration/localization) to use for any returned documents. |
|
|
76
|
+
| `overrideAccess` | Skip access control. By default, this property is set to true within all Local API operations. |
|
|
77
|
+
| `user` | If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
|
|
78
|
+
| `showHiddenFields` | Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
|
|
79
|
+
| `queryHiddenFields` | Allow querying by hidden fields. By default, hidden fields are not allowed to be queried on. |
|
|
80
|
+
| `pagination` | Set to false to return all documents and avoid querying for document counts. |
|
|
81
|
+
|
|
82
|
+
_There are more options available on an operation by operation basis outlined below._
|
|
72
83
|
|
|
73
84
|
<Banner type="warning">
|
|
74
|
-
<strong>Note:</strong
|
|
75
|
-
|
|
85
|
+
<strong>Note:</strong>
|
|
86
|
+
<br />
|
|
87
|
+
By default, all access control checks are disabled in the Local API, but you
|
|
88
|
+
can re-enable them if you'd like, as well as pass a specific user to run the
|
|
89
|
+
operation with.
|
|
76
90
|
</Banner>
|
|
77
91
|
|
|
78
92
|
## Collections
|
|
@@ -84,12 +98,13 @@ The following Collection operations are available through the Local API:
|
|
|
84
98
|
```js
|
|
85
99
|
// The created Post document is returned
|
|
86
100
|
const post = await payload.create({
|
|
87
|
-
collection:
|
|
88
|
-
data: {
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
collection: "posts", // required
|
|
102
|
+
data: {
|
|
103
|
+
// required
|
|
104
|
+
title: "sure",
|
|
105
|
+
description: "maybe",
|
|
91
106
|
},
|
|
92
|
-
locale:
|
|
107
|
+
locale: "en",
|
|
93
108
|
fallbackLocale: false,
|
|
94
109
|
user: dummyUserDoc,
|
|
95
110
|
overrideAccess: true,
|
|
@@ -102,12 +117,12 @@ const post = await payload.create({
|
|
|
102
117
|
// If your collection supports uploads, you can upload
|
|
103
118
|
// a file directly through the Local API by providing
|
|
104
119
|
// its full, absolute file path.
|
|
105
|
-
filePath: path.resolve(__dirname,
|
|
120
|
+
filePath: path.resolve(__dirname, "./path-to-image.jpg"),
|
|
106
121
|
|
|
107
122
|
// Alternatively, you can directly pass a File,
|
|
108
123
|
// if file is provided, filePath will be omitted
|
|
109
124
|
file: uploadedFile,
|
|
110
|
-
})
|
|
125
|
+
});
|
|
111
126
|
```
|
|
112
127
|
|
|
113
128
|
#### Find
|
|
@@ -116,18 +131,19 @@ const post = await payload.create({
|
|
|
116
131
|
// Result will be a paginated set of Posts.
|
|
117
132
|
// See /docs/queries/pagination for more.
|
|
118
133
|
const result = await payload.find({
|
|
119
|
-
collection:
|
|
134
|
+
collection: "posts", // required
|
|
120
135
|
depth: 2,
|
|
121
136
|
page: 1,
|
|
122
137
|
limit: 10,
|
|
123
138
|
where: {}, // pass a `where` query here
|
|
124
|
-
sort:
|
|
125
|
-
locale:
|
|
139
|
+
sort: "-title",
|
|
140
|
+
locale: "en",
|
|
126
141
|
fallbackLocale: false,
|
|
127
142
|
user: dummyUser,
|
|
128
143
|
overrideAccess: false,
|
|
129
144
|
showHiddenFields: true,
|
|
130
|
-
|
|
145
|
+
queryHiddenFields: false,
|
|
146
|
+
});
|
|
131
147
|
```
|
|
132
148
|
|
|
133
149
|
#### Find by ID
|
|
@@ -135,15 +151,15 @@ const result = await payload.find({
|
|
|
135
151
|
```js
|
|
136
152
|
// Result will be a Post document.
|
|
137
153
|
const result = await payload.findByID({
|
|
138
|
-
collection:
|
|
139
|
-
id:
|
|
154
|
+
collection: "posts", // required
|
|
155
|
+
id: "507f1f77bcf86cd799439011", // required
|
|
140
156
|
depth: 2,
|
|
141
|
-
locale:
|
|
157
|
+
locale: "en",
|
|
142
158
|
fallbackLocale: false,
|
|
143
159
|
user: dummyUser,
|
|
144
160
|
overrideAccess: false,
|
|
145
161
|
showHiddenFields: true,
|
|
146
|
-
})
|
|
162
|
+
});
|
|
147
163
|
```
|
|
148
164
|
|
|
149
165
|
#### Update
|
|
@@ -151,14 +167,15 @@ const result = await payload.findByID({
|
|
|
151
167
|
```js
|
|
152
168
|
// Result will be the updated Post document.
|
|
153
169
|
const result = await payload.update({
|
|
154
|
-
collection:
|
|
155
|
-
id:
|
|
156
|
-
data: {
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
collection: "posts", // required
|
|
171
|
+
id: "507f1f77bcf86cd799439011", // required
|
|
172
|
+
data: {
|
|
173
|
+
// required
|
|
174
|
+
title: "sure",
|
|
175
|
+
description: "maybe",
|
|
159
176
|
},
|
|
160
177
|
depth: 2,
|
|
161
|
-
locale:
|
|
178
|
+
locale: "en",
|
|
162
179
|
fallbackLocale: false,
|
|
163
180
|
user: dummyUser,
|
|
164
181
|
overrideAccess: false,
|
|
@@ -167,13 +184,13 @@ const result = await payload.update({
|
|
|
167
184
|
// If your collection supports uploads, you can upload
|
|
168
185
|
// a file directly through the Local API by providing
|
|
169
186
|
// its full, absolute file path.
|
|
170
|
-
filePath: path.resolve(__dirname,
|
|
187
|
+
filePath: path.resolve(__dirname, "./path-to-image.jpg"),
|
|
171
188
|
|
|
172
189
|
// If you are uploading a file and would like to replace
|
|
173
190
|
// the existing file instead of generating a new filename,
|
|
174
191
|
// you can set the following property to `true`
|
|
175
192
|
overwriteExistingFiles: true,
|
|
176
|
-
})
|
|
193
|
+
});
|
|
177
194
|
```
|
|
178
195
|
|
|
179
196
|
#### Delete
|
|
@@ -181,15 +198,15 @@ const result = await payload.update({
|
|
|
181
198
|
```js
|
|
182
199
|
// Result will be the now-deleted Post document.
|
|
183
200
|
const result = await payload.delete({
|
|
184
|
-
collection:
|
|
185
|
-
id:
|
|
201
|
+
collection: "posts", // required
|
|
202
|
+
id: "507f1f77bcf86cd799439011", // required
|
|
186
203
|
depth: 2,
|
|
187
|
-
locale:
|
|
204
|
+
locale: "en",
|
|
188
205
|
fallbackLocale: false,
|
|
189
206
|
user: dummyUser,
|
|
190
207
|
overrideAccess: false,
|
|
191
208
|
showHiddenFields: true,
|
|
192
|
-
})
|
|
209
|
+
});
|
|
193
210
|
```
|
|
194
211
|
|
|
195
212
|
## Auth Operations
|
|
@@ -207,19 +224,20 @@ If a collection has [`Authentication`](/docs/authentication/overview) enabled, a
|
|
|
207
224
|
// }
|
|
208
225
|
|
|
209
226
|
const result = await payload.login({
|
|
210
|
-
collection:
|
|
211
|
-
data: {
|
|
212
|
-
|
|
213
|
-
|
|
227
|
+
collection: "users", // required
|
|
228
|
+
data: {
|
|
229
|
+
// required
|
|
230
|
+
email: "dev@payloadcms.com",
|
|
231
|
+
password: "rip",
|
|
214
232
|
},
|
|
215
233
|
req: req, // pass an Express `req` which will be provided to all hooks
|
|
216
234
|
res: res, // used to automatically set an HTTP-only auth cookie
|
|
217
235
|
depth: 2,
|
|
218
|
-
locale:
|
|
236
|
+
locale: "en",
|
|
219
237
|
fallbackLocale: false,
|
|
220
238
|
overrideAccess: false,
|
|
221
239
|
showHiddenFields: true,
|
|
222
|
-
})
|
|
240
|
+
});
|
|
223
241
|
```
|
|
224
242
|
|
|
225
243
|
#### Forgot Password
|
|
@@ -227,12 +245,13 @@ const result = await payload.login({
|
|
|
227
245
|
```js
|
|
228
246
|
// Returned token will allow for a password reset
|
|
229
247
|
const token = await payload.forgotPassword({
|
|
230
|
-
collection:
|
|
231
|
-
data: {
|
|
232
|
-
|
|
248
|
+
collection: "users", // required
|
|
249
|
+
data: {
|
|
250
|
+
// required
|
|
251
|
+
email: "dev@payloadcms.com",
|
|
233
252
|
},
|
|
234
253
|
req: req, // pass an Express `req` which will be provided to all hooks
|
|
235
|
-
})
|
|
254
|
+
});
|
|
236
255
|
```
|
|
237
256
|
|
|
238
257
|
#### Reset Password
|
|
@@ -244,13 +263,14 @@ const token = await payload.forgotPassword({
|
|
|
244
263
|
// user: { ... } // the user document that just logged in
|
|
245
264
|
// }
|
|
246
265
|
const result = await payload.forgotPassword({
|
|
247
|
-
collection:
|
|
248
|
-
data: {
|
|
249
|
-
|
|
266
|
+
collection: "users", // required
|
|
267
|
+
data: {
|
|
268
|
+
// required
|
|
269
|
+
token: "afh3o2jf2p3f...", // the token generated from the forgotPassword operation
|
|
250
270
|
},
|
|
251
271
|
req: req, // pass an Express `req` which will be provided to all hooks
|
|
252
272
|
res: res, // used to automatically set an HTTP-only auth cookie
|
|
253
|
-
})
|
|
273
|
+
});
|
|
254
274
|
```
|
|
255
275
|
|
|
256
276
|
#### Unlock
|
|
@@ -258,13 +278,14 @@ const result = await payload.forgotPassword({
|
|
|
258
278
|
```js
|
|
259
279
|
// Returned result will be a boolean representing success or failure
|
|
260
280
|
const result = await payload.unlock({
|
|
261
|
-
collection:
|
|
262
|
-
data: {
|
|
263
|
-
|
|
281
|
+
collection: "users", // required
|
|
282
|
+
data: {
|
|
283
|
+
// required
|
|
284
|
+
email: "dev@payloadcms.com",
|
|
264
285
|
},
|
|
265
286
|
req: req, // pass an Express `req` which will be provided to all hooks
|
|
266
287
|
overrideAccess: true,
|
|
267
|
-
})
|
|
288
|
+
});
|
|
268
289
|
```
|
|
269
290
|
|
|
270
291
|
#### Verify
|
|
@@ -272,9 +293,9 @@ const result = await payload.unlock({
|
|
|
272
293
|
```js
|
|
273
294
|
// Returned result will be a boolean representing success or failure
|
|
274
295
|
const result = await payload.verify({
|
|
275
|
-
collection:
|
|
276
|
-
token:
|
|
277
|
-
})
|
|
296
|
+
collection: "users", // required
|
|
297
|
+
token: "afh3o2jf2p3f...", // the token saved on the user as `_verificationToken`
|
|
298
|
+
});
|
|
278
299
|
```
|
|
279
300
|
|
|
280
301
|
## Globals
|
|
@@ -286,14 +307,14 @@ The following Global operations are available through the Local API:
|
|
|
286
307
|
```js
|
|
287
308
|
// Result will be the Header Global.
|
|
288
309
|
const result = await payload.findGlobal({
|
|
289
|
-
slug:
|
|
310
|
+
slug: "header", // required
|
|
290
311
|
depth: 2,
|
|
291
|
-
locale:
|
|
312
|
+
locale: "en",
|
|
292
313
|
fallbackLocale: false,
|
|
293
314
|
user: dummyUser,
|
|
294
315
|
overrideAccess: false,
|
|
295
316
|
showHiddenFields: true,
|
|
296
|
-
})
|
|
317
|
+
});
|
|
297
318
|
```
|
|
298
319
|
|
|
299
320
|
#### Update
|
|
@@ -301,44 +322,79 @@ const result = await payload.findGlobal({
|
|
|
301
322
|
```js
|
|
302
323
|
// Result will be the updated Header Global.
|
|
303
324
|
const result = await payload.updateGlobal({
|
|
304
|
-
slug:
|
|
305
|
-
data: {
|
|
325
|
+
slug: "header", // required
|
|
326
|
+
data: {
|
|
327
|
+
// required
|
|
306
328
|
nav: [
|
|
307
329
|
{
|
|
308
|
-
url:
|
|
330
|
+
url: "https://google.com",
|
|
309
331
|
},
|
|
310
332
|
{
|
|
311
|
-
url:
|
|
333
|
+
url: "https://payloadcms.com",
|
|
312
334
|
},
|
|
313
335
|
],
|
|
314
336
|
},
|
|
315
337
|
depth: 2,
|
|
316
|
-
locale:
|
|
338
|
+
locale: "en",
|
|
317
339
|
fallbackLocale: false,
|
|
318
340
|
user: dummyUser,
|
|
319
341
|
overrideAccess: false,
|
|
320
342
|
showHiddenFields: true,
|
|
321
|
-
})
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Example Script using Local API
|
|
347
|
+
|
|
348
|
+
The Local API is especially useful for running scripts
|
|
349
|
+
|
|
350
|
+
```ts
|
|
351
|
+
import payload from "payload";
|
|
352
|
+
import path from "path";
|
|
353
|
+
import dotenv from "dotenv";
|
|
354
|
+
|
|
355
|
+
dotenv.config({
|
|
356
|
+
path: path.resolve(__dirname, "../.env"),
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
const { PAYLOAD_SECRET, MONGODB_URI } = process.env;
|
|
360
|
+
|
|
361
|
+
const doAction = async (): Promise<void> => {
|
|
362
|
+
await payload.init({
|
|
363
|
+
secret: PAYLOAD_SECRET,
|
|
364
|
+
mongoURL: MONGODB_URI,
|
|
365
|
+
local: true, // Enables local mode, doesn't spin up a server or frontend
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// Perform any Local API operations here
|
|
369
|
+
await payload.find({
|
|
370
|
+
collection: "posts",
|
|
371
|
+
// where: {} // optional
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
await payload.create({
|
|
375
|
+
collection: "posts",
|
|
376
|
+
data: {},
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
doAction();
|
|
322
381
|
```
|
|
323
382
|
|
|
324
383
|
## TypeScript
|
|
325
384
|
|
|
326
|
-
Local API calls
|
|
385
|
+
Local API calls will automatically infer your [generated types](/docs/typescript/generating-types).
|
|
327
386
|
|
|
328
387
|
Here is an example of usage:
|
|
329
388
|
|
|
330
389
|
```ts
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
// Add Post types as generic to create function
|
|
335
|
-
const post: Post = await payload.create<Post>({
|
|
336
|
-
collection: 'posts',
|
|
390
|
+
// Properly inferred as `Post` type
|
|
391
|
+
const post = await payload.create({
|
|
392
|
+
collection: "posts",
|
|
337
393
|
|
|
338
394
|
// Data will now be typed as Post and give you type hints
|
|
339
395
|
data: {
|
|
340
|
-
title:
|
|
341
|
-
description:
|
|
396
|
+
title: "my title",
|
|
397
|
+
description: "my description",
|
|
342
398
|
},
|
|
343
|
-
})
|
|
399
|
+
});
|
|
344
400
|
```
|
|
@@ -47,7 +47,7 @@ Before running in Production, you need to have built a production-ready copy of
|
|
|
47
47
|
{
|
|
48
48
|
"name": "project-name-here",
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build": "payload build"
|
|
50
|
+
"build": "payload build"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
// your dependencies
|
|
@@ -70,6 +70,8 @@ Payload comes with a robust set of built-in anti-abuse measures, such as locking
|
|
|
70
70
|
|
|
71
71
|
## MongoDB
|
|
72
72
|
|
|
73
|
+
Payload can be used with any MongoDB compatible database including AWS DocumentDB or Azure Cosmos DB.
|
|
74
|
+
|
|
73
75
|
##### Managing MongoDB yourself
|
|
74
76
|
|
|
75
77
|
If you are using a [persistent filesystem-based cloud host](#persistent-vs-ephemeral-filesystems) such as a [DigitalOcean Droplet](https://www.digitalocean.com/products/droplets/) or an [Amazon EC2](https://aws.amazon.com/ec2/?ec2-whats-new.sort-by=item.additionalFields.postDateTime&ec2-whats-new.sort-order=desc) server, you might opt to install MongoDB directly on that server itself so that Node can communicate with it locally. With this approach, you can benefit from faster response times, but scaling can become more involved as your app's user base grows.
|
|
@@ -78,10 +80,11 @@ If you are using a [persistent filesystem-based cloud host](#persistent-vs-ephem
|
|
|
78
80
|
|
|
79
81
|
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.
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
##### DocumentDB
|
|
84
|
+
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.
|
|
85
|
+
|
|
86
|
+
##### CosmosDB
|
|
87
|
+
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.
|
|
85
88
|
|
|
86
89
|
## File storage
|
|
87
90
|
|