UNPKG

payloadcms-import-export-plugin

Version:

A comprehensive Payload CMS plugin that enables seamless import and export of collection data with support for CSV and JSON formats, featuring advanced field mapping, duplicate handling, and batch processing capabilities.

23 lines (22 loc) 732 B
/** * Takes an input of array of string paths in dot notation and returns a select object * example args: ['id', 'title', 'group.value', 'createdAt', 'updatedAt'] */ export const getSelect = (fields)=>{ const select = {}; fields.forEach((field)=>{ const segments = field.split('.'); let selectRef = select; segments.forEach((segment, i)=>{ if (i === segments.length - 1) { selectRef[segment] = true; } else { if (!selectRef[segment]) { selectRef[segment] = {}; } selectRef = selectRef[segment]; } }); }); return select; }; //# sourceMappingURL=getSelect.js.map