Function: SoftDelete()
SoftDelete(
columnNameOrOptions?):any
Defined in: src/decorators/SoftDelete.ts:47
Class or Property decorator to enable soft deletion for an entity model.
When an entity is soft-deleted with context.set(Entity).remove(id), the ORM updates
this column with the current deletion timestamp instead of physically removing the row.
Subsequent queries automatically exclude rows where deletedAt IS NOT NULL, unless .withDeleted() is used.
Parameters
| Parameter | Type | Description |
|---|---|---|
columnNameOrOptions? | string | SoftDeleteOptions | Optional column name, or an options object with { column, cascade }. |
Returns
any
Usecase
Safely retain records for audits or recovery instead of permanent physical data loss.
Example
// Basic soft-delete
@SoftDelete()
deletedAt?: Date;
// With cascade — removing a User also soft-deletes their Posts
@Table('users')
@SoftDelete({ cascade: true })
export class User { ... }