If you would like to use a different column to hold the
deleted status, you can specify a custom column in your model,
like so:
@SoftDelete()
class Post extends ApplicationModel {
public get deletedAtField() {
return 'customDatetimeField' as const
}
}
Note on indexing: Dream deliberately does not index deleted_at.
The default scope's WHERE deleted_at IS NULL matches nearly every
row on a healthy table, so a plain b-tree on the column is rarely
chosen by the planner while still costing index size and write
amplification, and Dream itself never issues a query such an index
could serve. If your app needs one, add it yourself based on your
own access patterns — on Postgres, the two useful shapes are a
composite partial index on your hot lookup columns with
WHERE deleted_at IS NULL (fast scoped reads), or a partial index
WHERE deleted_at IS NOT NULL (purge/GC sweeps over soft-deleted
rows). Both are Postgres-specific syntax.
Instructs the model to set a timestamp when deleting, rather than actually removing the record from the database.
By default, the SoftDelete decorator will expect a
deletedAtfield to be set on your model, pointing to atimestampfield in the database, like so:If you would like to use a different column to hold the deleted status, you can specify a custom column in your model, like so:
@SoftDelete() class Post extends ApplicationModel { public get deletedAtField() { return 'customDatetimeField' as const } }
Note on indexing: Dream deliberately does not index
deleted_at. The default scope'sWHERE deleted_at IS NULLmatches nearly every row on a healthy table, so a plain b-tree on the column is rarely chosen by the planner while still costing index size and write amplification, and Dream itself never issues a query such an index could serve. If your app needs one, add it yourself based on your own access patterns — on Postgres, the two useful shapes are a composite partial index on your hot lookup columns withWHERE deleted_at IS NULL(fast scoped reads), or a partial indexWHERE deleted_at IS NOT NULL(purge/GC sweeps over soft-deleted rows). Both are Postgres-specific syntax.