softdelete

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplySoftDeleteFilter

func ApplySoftDeleteFilter(builder *query.QueryBuilder, showTrashed bool)

ApplySoftDeleteFilter adds a WHERE deleted_at IS NULL clause to the query unless showTrashed is true. Call this when building list/get queries for entities that have soft delete enabled.

func ForceDelete

func ForceDelete(ctx context.Context, db *sql.DB, table string, id string) error

ForceDelete permanently removes a record from the database. This bypasses soft delete and performs a real DELETE.

func Restore

func Restore(ctx context.Context, db *sql.DB, table string, id string) error

Restore clears the deleted_at field, making a soft-deleted record visible again.

func SoftDelete

func SoftDelete(ctx context.Context, db *sql.DB, table string, id string) error

SoftDelete marks a record as deleted by setting deleted_at to NOW(). The record remains in the database but will be excluded from normal queries.

func WithSoftDelete

func WithSoftDelete(ent *entity.Entity) *entity.Entity

WithSoftDelete configures an entity for soft delete support. Sets the SoftDelete flag so the framework knows to use UPDATE instead of DELETE.

func WithTrashed

func WithTrashed(r *http.Request) bool

WithTrashed checks whether the request asks to include soft-deleted records. Returns true when the query parameter ?trashed=true is present.

Types

type SoftDeleteScope

type SoftDeleteScope struct{}

SoftDeleteScope is a query scope that filters out soft-deleted records. When applied to a QueryBuilder, it adds WHERE deleted_at IS NULL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL