Documentation
¶
Index ¶
- func ApplySoftDeleteFilter(builder *query.QueryBuilder, showTrashed bool)
- func ForceDelete(ctx context.Context, db *sql.DB, table string, id string) error
- func Restore(ctx context.Context, db *sql.DB, table string, id string) error
- func SoftDelete(ctx context.Context, db *sql.DB, table string, id string) error
- func WithSoftDelete(ent *entity.Entity) *entity.Entity
- func WithTrashed(r *http.Request) bool
- type SoftDeleteScope
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 ¶
ForceDelete permanently removes a record from the database. This bypasses soft delete and performs a real DELETE.
func SoftDelete ¶
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 ¶
WithSoftDelete configures an entity for soft delete support. Sets the SoftDelete flag so the framework knows to use UPDATE instead of DELETE.
func WithTrashed ¶
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.