UNPKG

strapi-plugin-soft-delete

Version:

Add a soft delete feature to your project

40 lines (39 loc) 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("../utils"); exports.default = ({ strapi }) => { for (let contentTypeRecord of Object.entries(strapi.contentTypes) // .concat(Object.entries(strapi.components)) // TODO: Deleting a compoment doesn't use the entityService.delete nor entityService.deleteMany ) { const [uid, contentType] = contentTypeRecord; if (utils_1.plugin.supportsContentType(uid)) { const _softDeletedAt = { type: "datetime", configurable: false, writable: false, visible: false, private: true, }; contentType.attributes._softDeletedAt = _softDeletedAt; contentType.__schema__.attributes._softDeletedAt = _softDeletedAt; const _softDeletedById = { type: "integer", configurable: false, writable: false, visible: false, private: true, }; contentType.attributes._softDeletedById = _softDeletedById; contentType.__schema__.attributes._softDeletedById = _softDeletedById; const _softDeletedByType = { type: "string", configurable: false, writable: false, visible: false, private: true, }; contentType.attributes._softDeletedByType = _softDeletedByType; contentType.__schema__.attributes._softDeletedByType = _softDeletedByType; } } };