Skip to content

docs: document soft-remove and recover alongside soft-delete#12552

Open
emmayusufu wants to merge 1 commit into
typeorm:masterfrom
emmayusufu:docs/soft-remove-vs-soft-delete
Open

docs: document soft-remove and recover alongside soft-delete#12552
emmayusufu wants to merge 1 commit into
typeorm:masterfrom
emmayusufu:docs/soft-remove-vs-soft-delete

Conversation

@emmayusufu

Copy link
Copy Markdown

The soft-delete docs only cover the QueryBuilder softDelete() / restore(), so softRemove() / recover() are easy to miss, which is what #12251 ran into.

Added a short section to the delete page explaining the difference: softDelete / restore are bulk updates by criteria, while softRemove / recover work on entity instances and run cascades plus the @BeforeSoftRemove / @AfterSoftRemove / @BeforeRecover / @AfterRecover listeners. Includes a small example and links to the Repository API and Listeners and Subscribers pages.

Closes #12251

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1)

Grey Divider


Remediation recommended

1. Soft-Remove heading misnames API 📘 Rule violation ⚙ Maintainability
Description
The new section title uses Soft-Remove / Recover, which does not match the actual API method
naming (softRemove() / recover()). This can confuse users and deviates from established naming
conventions shown elsewhere in the doc.
Code

docs/docs/query-builder/4-delete-query-builder.md[R57-58]

Evidence
PR Compliance ID 1 requires consistent naming conventions for identifiers; the section title
introduces a code-formatted name (Soft-Remove) that does not correspond to the actual camelCase
method name used by the API, making naming inconsistent within the docs.

Rule 1: Consistent Naming Conventions
docs/docs/query-builder/4-delete-query-builder.md[57-58]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new docs section title uses `Soft-Remove` and `Recover`, which are not the actual public API method names.

## Issue Context
The rest of the page documents methods like `softDelete()` / `restore()` using the exact method names. The title should follow the same convention to avoid misleading readers.

## Fix Focus Areas
- docs/docs/query-builder/4-delete-query-builder.md[57-58]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Wrong subscriber behavior claim 🐞 Bug ≡ Correctness
Description
The new section says QueryBuilder softDelete()/restore() “skips ... subscribers”, but
SoftDeleteQueryBuilder.execute() broadcasts BeforeSoftRemove/AfterSoftRemove and
BeforeRecover/AfterRecover when listeners are enabled (default). Subscribers therefore still run
(typically with event.entity undefined), so the docs are misleading and can cause subscriber
implementations to throw at runtime if they assume a loaded entity instance.
Code

docs/docs/query-builder/4-delete-query-builder.md[59]

Evidence
QueryBuilder soft-delete/restore broadcasts soft-remove/recover events when callListeners is
enabled (and it is by default). The broadcaster executes subscribers regardless of whether an entity
instance exists, so subscribers are not skipped—only entity listeners are skipped due to missing
entity.

src/query-builder/QueryExpressionMap.ts[303-307]
src/query-builder/SoftDeleteQueryBuilder.ts[58-87]
src/query-builder/SoftDeleteQueryBuilder.ts[122-137]
src/subscriber/Broadcaster.ts[105-118]
src/subscriber/Broadcaster.ts[302-343]
src/subscriber/event/RemoveEvent.ts[7-13]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The docs claim QueryBuilder `softDelete()` / `restore()` skip “entity listeners or subscribers”. In reality, QueryBuilder soft-delete/restore broadcasts soft-remove/recover events to subscribers by default; entity listeners don’t run because there is no entity instance.

## Issue Context
- `SoftDeleteQueryBuilder.execute()` broadcasts `BeforeSoftRemove`/`AfterSoftRemove` or `BeforeRecover`/`AfterRecover` when `callListeners` is true.
- `callListeners` defaults to true.
- `Broadcaster` executes subscribers even when `entity` is undefined; entity listeners are only executed when an entity instance is provided.

## Fix Focus Areas
- docs/docs/query-builder/4-delete-query-builder.md[59-62]

## Suggested wording (example)
Replace the sentence with something like:
> "...it doesn't load the entities, so it skips cascades and entity listeners. Subscribers may still run, but they won't receive entity instances (event.entity may be undefined)."

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Qodo Logo

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

Development

Successfully merging this pull request may close these issues.

Documentation lacking for 'soft-remove'

1 participant