softdelete

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const FieldDeletedAt = "deleted_at"

FieldDeletedAt holds the column name for the "deleted_at" field.

View Source
const ParamTrashed = "trashed"

ParamTrashed is the name of the query parameter to include trashed items

Variables

This section is empty.

Functions

func AddDeletedAtField

func AddDeletedAtField(schema *ogen.Schema)

AddDeletedAtField adds the "deleted_at" field to the oas schema

func AddRestoreEndpoint

func AddRestoreEndpoint(
	name string, spec *ogen.Spec, basePath string, idParam *ogen.Parameter,
) error

AddRestoreEndpoint adds the restore endpoint to the OpenAPI spec

func AttachTo

func AttachTo(
	name string, spec *ogen.Spec, base string, item *ogen.Schema,
	idParam *ogen.Parameter,
) error

AttachTo adds fields, parameters, and endpoints necessary to the soft delete pattern to the given OpenAPI spec, with the given ID parameter name.

func IncludeTrashed

func IncludeTrashed(parent context.Context) context.Context

IncludeTrashed returns a new context that skips the soft-delete interceptor/mutators.

func Interceptor

func Interceptor[Q interface{ WhereP(...func(*sql.Selector)) }](
	f func(ent.Query) (Q, error),
) ent.Interceptor

Interceptor returns a new ent.Interceptor that implements the soft delete pattern.

func Mutator

func Mutator[M interface {
	Mutate(context.Context, ent.Mutation) (ent.Value, error)
}]() ent.Hook

Mutator returns a new ent.Hook that implements the soft delete pattern.

func NewSoftDeleteQueryContext

func NewSoftDeleteQueryContext(
	withTrashed *bool, ctx context.Context,
) context.Context

NewSoftDeleteQueryContext returns a new context that includes the soft delete pattern. If `ctx` is nil, it will create a new context.Background(). calls `IncludeTrashed` if `withTrashed` is `true`.

func TrashedParam

func TrashedParam() *ogen.Parameter

TrashedParam returns the `trashed` query parameter

Types

type Mixin

type Mixin struct {
	mixin.Schema
}

Mixin implements the soft delete pattern for schemas.

func (Mixin) Fields

func (Mixin) Fields() []ent.Field

Fields of the SoftDeleteMixin. Once you declare "deleted_at" in here, you MUST DELETE IT from the entity that will use that Mixin

Jump to

Keyboard shortcuts

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