芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/.cache/admin/src/utils/getAttributesToDisplay.js
import { get } from 'lodash'; const getAttributesToDisplay = contentType => { const timestamps = get(contentType, ['options', 'timestamps']); // Sometimes timestamps is false let timestampsArray = Array.isArray(timestamps) ? timestamps : []; const idsAttributes = ['id', '_id']; // For both SQL and mongo const unwritableAttributes = [...idsAttributes, ...timestampsArray, 'published_at']; const schemaAttributes = get(contentType, ['attributes'], {}); return Object.keys(schemaAttributes).reduce((acc, current) => { if (!unwritableAttributes.includes(current)) { acc.push({ ...schemaAttributes[current], attributeName: current }); } return acc; }, []); }; export default getAttributesToDisplay;