docs_headless/src/content/docs/addSoftDeleteInPlace.md
This helper function wraps an existing dataProvider to add the soft delete capabilities, keeping the deleted records in the same resource. This implementation will simply fill the deleted_at (configurable) and deleted_by (configurable) fields.
This feature requires a valid Enterprise Edition subscription.
npm install --save @react-admin/ra-core-ee
# or
yarn add @react-admin/ra-core-ee
You'll need to pass an object with all your resources as key so that getListDeleted knows where to look for deleted records.
Note on performances: Avoid calling
getListDeletedwithout aresourcefilter, as it uses a naive implementation combining multiplegetListcalls, which can lead to bad performances. It is recommended to use one list per resource in this case (seeresourceproperty).
// in src/dataProvider.ts
import { addSoftDeleteInPlace } from '@react-admin/ra-core-ee';
import baseDataProvider from './baseDataProvider';
export const dataProvider = addSoftDeleteInPlace(
baseDataProvider,
{
posts: {},
comments: {
deletedAtFieldName: 'deletion_date',
},
accounts: {
deletedAtFieldName: 'disabled_at',
deletedByFieldName: 'disabled_by',
}
}
);