Adds soft deletion to selected Payload collections by marking documents with a deletedAt field instead of removing them. Configured per collection in the plugins array, with options to enable restore, enable hard delete and restrict soft delete access. The plugin is in maintenance mode, as Payload 3.49.0 and later includes a built-in trash feature; it requires Payload 3.39.0 or later.
never lose your payload documents again
Installation
npm i @payload-bites/soft-delete114
Stars
6
Forks
0
Open Issues
3 weeks ago
Last Updated
0
Weekly Downloads
v3.3.0
npm Version
253.4 KB
Unpacked Size
0
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Shared by 7 plugins in rilrom/payload-bites.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/908347705-soft-delete)<a href="https://payloaddirectory.dev/plugins/908347705-soft-delete"><img src="https://payloaddirectory.dev/badge/908347705-soft-delete.svg" alt="Payload Directory"></a>README
Never lose your Payload documents again, soft delete is here to save the day.
[!IMPORTANT] This plugin has been moved to maintenance mode due the release of the trash feature. From v3.49.0 onwards, I recommend using the implementation in the core product instead.
https://github.com/user-attachments/assets/4d7334d1-d7f2-4ab7-9421-0c84dfcf38cb
| Payload version | Soft delete version |
|---|---|
| v3.23.0 or earlier | Incompatible |
| v3.24.0 to 3.38.0 | v1.x |
| v3.39.0 to 3.50.0 | v2.x |
| v3.51.0 or later | v3.x |
pnpm add @payload-bites/soft-delete
payload.config.ts:// ...
import { softDeletePlugin } from "@payload-bites/soft-delete";
export default buildConfig({
// ...
plugins: [
// ...
softDeletePlugin({
collections: {
posts: {},
"posts-with-drafts": {
// ...
enableRestore: false,
enableHardDelete: false,
softDeleteAccess: (args) => args.req.user.role === "admin",
},
},
}),
],
});
For defaults, refer to defaults.ts.
For options, refer to types.ts.
You can retrieve active or soft deleted documents by checking for the existence of the deletedAt field.
const result = await payload.find({
collection: "posts",
where: {
deletedAt: {
exists: false,
},
},
});
import { stringify } from "qs-esm";
import type { Where } from "payload";
const query: Where = {
deletedAt: {
exists: false,
},
};
const getPosts = async () => {
const stringifiedQuery = stringify(
{
where: query,
},
{ addQueryPrefix: true },
);
const response = await fetch(
`http://localhost:3000/api/posts${stringifiedQuery}`,
);
};
query {
Posts(where: { deletedAt: { exists: false } }) {
docs {
title
}
}
}
Topics
payload better editor
Side-by-side live preview iframe with a sidebar for editing individual blocks in the Payload edit view
710/wk113v3
payload plugin scheduler
Date field that queues native scheduled-publish jobs for drafts, with schedule status shown in the admin
6727/wk32v3
content freeze
Block create, update and delete on chosen collections and globals while a content freeze is active
660/wk114v3
payload isr
Revalidate Next.js paths and cache tags when Payload documents change, with optional full rebuild fallback
650/wk3v3
payload markdown docs
Sync a repo-local Markdown docs tree into Payload and render it in a Next.js site
630/wk4v3
payload live nav
Section index and field focus bridge that syncs the Payload edit form with Live Preview
628/wk0v3