hook

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixedError

func FixedError(err error) ent.Hook

FixedError is a hook returning a fixed error.

func If

func If(hk ent.Hook, cond Condition) ent.Hook

If executes the given hook under condition.

hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))

func On

func On(hk ent.Hook, op ent.Op) ent.Hook

On executes the given hook only for the given operation.

hook.On(Log, ent.Delete|ent.Create)

func Reject

func Reject(op ent.Op) ent.Hook

Reject returns a hook that rejects all operations that match op.

func (T) Hooks() []ent.Hook {
	return []ent.Hook{
		Reject(ent.Delete|ent.Update),
	}
}

func Unless

func Unless(hk ent.Hook, op ent.Op) ent.Hook

Unless skips the given hook only for the given operation.

hook.Unless(Log, ent.Update|ent.UpdateOne)

Types

type ApiKeyFunc

type ApiKeyFunc func(context.Context, *ent.ApiKeyMutation) (ent.Value, error)

The ApiKeyFunc type is an adapter to allow the use of ordinary function as ApiKey mutator.

func (ApiKeyFunc) Mutate

func (f ApiKeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

Chain acts as a list of hooks and is effectively immutable. Once created, it will always hold the same set of hooks in the same order.

func NewChain

func NewChain(hooks ...ent.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append

func (c Chain) Append(hooks ...ent.Hook) Chain

Append extends a chain, adding the specified hook as the last ones in the mutation flow.

func (Chain) Extend

func (c Chain) Extend(chain Chain) Chain

Extend extends a chain, adding the specified chain as the last ones in the mutation flow.

func (Chain) Hook

func (c Chain) Hook() ent.Hook

Hook chains the list of hooks and returns the final hook.

type Condition

type Condition func(context.Context, ent.Mutation) bool

Condition is a hook condition function.

func And

func And(first, second Condition, rest ...Condition) Condition

And groups conditions with the AND operator.

func HasAddedFields

func HasAddedFields(field string, fields ...string) Condition

HasAddedFields is a condition validating `.AddedField` on fields.

func HasClearedFields

func HasClearedFields(field string, fields ...string) Condition

HasClearedFields is a condition validating `.FieldCleared` on fields.

func HasFields

func HasFields(field string, fields ...string) Condition

HasFields is a condition validating `.Field` on fields.

func HasOp

func HasOp(op ent.Op) Condition

HasOp is a condition testing mutation operation.

func Not

func Not(cond Condition) Condition

Not negates a given condition.

func Or

func Or(first, second Condition, rest ...Condition) Condition

Or groups conditions with the OR operator.

type DownloadRecordFunc

type DownloadRecordFunc func(context.Context, *ent.DownloadRecordMutation) (ent.Value, error)

The DownloadRecordFunc type is an adapter to allow the use of ordinary function as DownloadRecord mutator.

func (DownloadRecordFunc) Mutate

Mutate calls f(ctx, m).

type EpisodeFunc

type EpisodeFunc func(context.Context, *ent.EpisodeMutation) (ent.Value, error)

The EpisodeFunc type is an adapter to allow the use of ordinary function as Episode mutator.

func (EpisodeFunc) Mutate

func (f EpisodeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type ImportScanFileFunc

type ImportScanFileFunc func(context.Context, *ent.ImportScanFileMutation) (ent.Value, error)

The ImportScanFileFunc type is an adapter to allow the use of ordinary function as ImportScanFile mutator.

func (ImportScanFileFunc) Mutate

Mutate calls f(ctx, m).

type ImportScanFunc

type ImportScanFunc func(context.Context, *ent.ImportScanMutation) (ent.Value, error)

The ImportScanFunc type is an adapter to allow the use of ordinary function as ImportScan mutator.

func (ImportScanFunc) Mutate

func (f ImportScanFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type ImportScanShowFunc

type ImportScanShowFunc func(context.Context, *ent.ImportScanShowMutation) (ent.Value, error)

The ImportScanShowFunc type is an adapter to allow the use of ordinary function as ImportScanShow mutator.

func (ImportScanShowFunc) Mutate

Mutate calls f(ctx, m).

type InviteFunc

type InviteFunc func(context.Context, *ent.InviteMutation) (ent.Value, error)

The InviteFunc type is an adapter to allow the use of ordinary function as Invite mutator.

func (InviteFunc) Mutate

func (f InviteFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type MediaFileFunc

type MediaFileFunc func(context.Context, *ent.MediaFileMutation) (ent.Value, error)

The MediaFileFunc type is an adapter to allow the use of ordinary function as MediaFile mutator.

func (MediaFileFunc) Mutate

func (f MediaFileFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type MovieEventFunc

type MovieEventFunc func(context.Context, *ent.MovieEventMutation) (ent.Value, error)

The MovieEventFunc type is an adapter to allow the use of ordinary function as MovieEvent mutator.

func (MovieEventFunc) Mutate

func (f MovieEventFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type MovieFunc

type MovieFunc func(context.Context, *ent.MovieMutation) (ent.Value, error)

The MovieFunc type is an adapter to allow the use of ordinary function as Movie mutator.

func (MovieFunc) Mutate

func (f MovieFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type OIDCIdentityFunc

type OIDCIdentityFunc func(context.Context, *ent.OIDCIdentityMutation) (ent.Value, error)

The OIDCIdentityFunc type is an adapter to allow the use of ordinary function as OIDCIdentity mutator.

func (OIDCIdentityFunc) Mutate

func (f OIDCIdentityFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type RequestFunc

type RequestFunc func(context.Context, *ent.RequestMutation) (ent.Value, error)

The RequestFunc type is an adapter to allow the use of ordinary function as Request mutator.

func (RequestFunc) Mutate

func (f RequestFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type ScheduledJobFunc

type ScheduledJobFunc func(context.Context, *ent.ScheduledJobMutation) (ent.Value, error)

The ScheduledJobFunc type is an adapter to allow the use of ordinary function as ScheduledJob mutator.

func (ScheduledJobFunc) Mutate

func (f ScheduledJobFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type SeasonFunc

type SeasonFunc func(context.Context, *ent.SeasonMutation) (ent.Value, error)

The SeasonFunc type is an adapter to allow the use of ordinary function as Season mutator.

func (SeasonFunc) Mutate

func (f SeasonFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type SessionFunc

type SessionFunc func(context.Context, *ent.SessionMutation) (ent.Value, error)

The SessionFunc type is an adapter to allow the use of ordinary function as Session mutator.

func (SessionFunc) Mutate

func (f SessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type TVShowFunc

type TVShowFunc func(context.Context, *ent.TVShowMutation) (ent.Value, error)

The TVShowFunc type is an adapter to allow the use of ordinary function as TVShow mutator.

func (TVShowFunc) Mutate

func (f TVShowFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type UserFunc

type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)

The UserFunc type is an adapter to allow the use of ordinary function as User mutator.

func (UserFunc) Mutate

func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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