Skip to content

Conversation

@DanRibbens
Copy link
Contributor

@DanRibbens DanRibbens commented May 23, 2025

This makes it possible to add custom logic into how we map the document data into the CSV data on a field-by-field basis.

  • Allow custom data transformation to be added to `custom.['plugin-import-export'].toCSV inside the field config
  • Add type declaration to FieldCustom to improve types
  • Export with depth: 1

Example:

 { name: 'customRelationship', type: 'relationship', relationTo: 'users', custom: { 'plugin-import-export': { toCSV: ({ value, columnName, row, siblingDoc, doc }) => { row[`${columnName}_id`] = value.id row[`${columnName}_email`] = value.email }, }, }, },
@DanRibbens DanRibbens marked this pull request as ready for review June 9, 2025 14:20
@DanRibbens DanRibbens requested a review from r1tsuu June 9, 2025 14:20
…eld-transform # Conflicts: #	packages/plugin-import-export/src/export/createExport.ts
@DanRibbens DanRibbens merged commit 8f4c442 into main Jun 9, 2025
77 checks passed
@DanRibbens DanRibbens deleted the feat/import-export-field-transform branch June 9, 2025 17:53
@DanRibbens DanRibbens restored the feat/import-export-field-transform branch June 9, 2025 18:05
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2025

🚀 This is included in version v3.42.0

elliott-w pushed a commit to elliott-w/payload that referenced this pull request Jun 12, 2025
…oadcms#12533) This makes it possible to add custom logic into how we map the document data into the CSV data on a field-by-field basis. - Allow custom data transformation to be added to `custom.['plugin-import-export'].toCSV inside the field config - Add type declaration to FieldCustom to improve types - Export with `depth: 1` Example: ```ts { name: 'customRelationship', type: 'relationship', relationTo: 'users', custom: { 'plugin-import-export': { toCSV: ({ value, columnName, row, siblingDoc, doc }) => { row[`${columnName}_id`] = value.id row[`${columnName}_email`] = value.email }, }, }, }, ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment