Skip to content

Commit f6afda8

Browse files
committed
docs(plugin-import-export): exports
1 parent 2131be6 commit f6afda8

File tree

1 file changed

+48
-13
lines changed

1 file changed

+48
-13
lines changed

docs/plugins/import-export.mdx

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,24 @@ export default config
5555

5656
## Options
5757

58-
| Property | Type | Description |
59-
| ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
60-
| collections | string[] | Collections to include Import/Export controls in. Defaults to all collections. |
61-
| debug | boolean | If true, enables debug logging. |
62-
| disableDownload | boolean | If true, disables the download button in the export preview UI. |
63-
| disableJobsQueue | boolean | If true, forces the export to run synchronously. |
64-
| disableSave | boolean | If true, disables the save button in the export preview UI. |
65-
| format | string | Forces a specific export format (`csv` or `json`), hides the format dropdown, and prevents the user from choosing the export format. |
66-
| overrideExportCollection | function | Function to override the default export collection; takes the default export collection and allows you to modify and return it. |
58+
| Property | Type | Description |
59+
| -------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
60+
| `collections` | string[] | Collections to include Import/Export controls in. Defaults to all collections. |
61+
| `debug` | boolean | If true, enables debug logging. |
62+
| `disableDownload` | boolean | If true, disables the download button in the export preview UI. |
63+
| `disableJobsQueue` | boolean | If true, forces the export to run synchronously. |
64+
| `disableSave` | boolean | If true, disables the save button in the export preview UI. |
65+
| `format` | string | Forces a specific export format (`csv` or `json`), hides the format dropdown, and prevents the user from choosing the export format. |
66+
| `overrideExportCollection` | function | Function to override the default export collection; takes the default export collection and allows you to modify and return it. |
6767

6868
## Field Options
6969

7070
In addition to the above plugin configuration options, you can granularly set the following field level options using the `custom['plugin-import-export']` properties in any of your collections.
7171

72-
| Property | Type | Description |
73-
| -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
74-
| disabled | boolean | When `true` the field is completely excluded from the import-export plugin. |
75-
| toCSV | function | Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value. |
72+
| Property | Type | Description |
73+
| ---------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
74+
| `disabled` | boolean | When `true` the field is completely excluded from the import-export plugin. |
75+
| `toCSV` | function | Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value. |
7676

7777
### Customizing the output of CSV data
7878

@@ -118,3 +118,38 @@ const pages: CollectionConfig = {
118118
],
119119
}
120120
```
121+
122+
## Exporting Data
123+
124+
There are four possible ways that the plugin allows for exporting documents, the first two are available in the admin UI from the list view of a collection:
125+
126+
1. Direct download - Using a `POST` to `/api/exports/download` and streams the response as a file download
127+
2. File storage - Goes to the `exports` collection as an uploads enabled collection
128+
3. Local API - A create call to the uploads collection: `payload.create({ slug: 'uploads', ...parameters })`
129+
4. Jobs Queue - `payload.jobs.queue({ task: 'createCollectionExport', input: parameters })`
130+
131+
By default, a user can use the Export drawer to create a file download by choosing `Save` or stream a downloadable file directly without persisting it by using the `Download` button. Either option can be disabled to provide the export experience you desire for your use-case.
132+
133+
The UI for creating exports provides options so that users can be selective about which documents to include and also which columns or fields to include.
134+
135+
It is necessary to add access control to the uploads collection configuration using the `overrideExportCollection` function if you have enabled this plugin on collections with data that some authenticated users should not have access to.
136+
137+
<Banner type="warning">
138+
**Note**: Users who have read access to the upload collection may be able to
139+
download data that is normally not readable due to [access
140+
control](../access-control/overview).
141+
</Banner>
142+
143+
The following parameters are used by the export function to handle requests:
144+
145+
| Property | Type | Description |
146+
| ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------- |
147+
| `format` | text | Either `csv` or `json` to determine the shape of data exported |
148+
| `limit` | number | The max number of documents to return |
149+
| `sort` | select | The field to use for ordering documents |
150+
| `locale` | string | The locale code to query documents or `all` |
151+
| `draft` | string | Either `yes` or `no` to return documents with their newest drafts for drafts enabled collections |
152+
| `fields` | string[] | Which collection fields are used to create the export, defaults to all |
153+
| `collectionSlug` | string | The slug to query against |
154+
| `where` | object | The WhereObject used to query documents to export. This is set by making selections or filters from the list view |
155+
| `filename` | text | What to call the export being created |

0 commit comments

Comments
 (0)