Skip to content

feat: soft delete #12656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft

feat: soft delete #12656

wants to merge 24 commits into from

Conversation

PatrikKozak
Copy link
Contributor

@PatrikKozak PatrikKozak commented Jun 2, 2025

What?

This PR introduces foundational backend support for soft delete functionality via a new softDeletes root-level property on collections. When enabled, collections support soft deletion by including a deletedAt timestamp on documents.

import type { CollectionConfig } from 'payload'

const Posts: CollectionConfig = {
  slug: 'posts',
  softDeletes: true, // <-- Newly add collection config prop @default false
  fields: [
    {
      name: 'title',
      type: 'text',
    },
    // other fields...
  ],
}

How?

  • New softDeletes config prop on collections.
  • Conditional injection of deletedAt field if softDeletes is enabled.
  • Extended support for trash query param across LOCAL, REST and GRAPHQL API operations:
    • find
    • findByID
    • findVersions
    • findVersionByID
    • update
    • updateByID
    • delete
    • deleteByID
  • Appended delete access control in update & updateByID operations to prevent soft deleting if restricted by delete access in the collection config.

Notes

  • This PR only introduces backend support and does not modify admin UI behavior. A separate frontend PR will expose the actual soft delete UI and interaction.

  • Fully covered by tests validating the behavior of all trash query params on soft-deletable collections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant