hook

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: AGPL-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 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 InterpretationFunc

type InterpretationFunc func(context.Context, *ent.InterpretationMutation) (ent.Value, error)

The InterpretationFunc type is an adapter to allow the use of ordinary function as Interpretation mutator.

func (InterpretationFunc) Mutate

Mutate calls f(ctx, m).

type InterpretationTranslationFunc

type InterpretationTranslationFunc func(context.Context, *ent.InterpretationTranslationMutation) (ent.Value, error)

The InterpretationTranslationFunc type is an adapter to allow the use of ordinary function as InterpretationTranslation mutator.

func (InterpretationTranslationFunc) Mutate

Mutate calls f(ctx, m).

type ItemFunc

type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error)

The ItemFunc type is an adapter to allow the use of ordinary function as Item mutator.

func (ItemFunc) Mutate

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

Mutate calls f(ctx, m).

type ItemTranslationFunc

type ItemTranslationFunc func(context.Context, *ent.ItemTranslationMutation) (ent.Value, error)

The ItemTranslationFunc type is an adapter to allow the use of ordinary function as ItemTranslation mutator.

func (ItemTranslationFunc) Mutate

Mutate calls f(ctx, m).

type NormFunc

type NormFunc func(context.Context, *ent.NormMutation) (ent.Value, error)

The NormFunc type is an adapter to allow the use of ordinary function as Norm mutator.

func (NormFunc) Mutate

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

Mutate calls f(ctx, m).

type QuestionFunc

type QuestionFunc func(context.Context, *ent.QuestionMutation) (ent.Value, error)

The QuestionFunc type is an adapter to allow the use of ordinary function as Question mutator.

func (QuestionFunc) Mutate

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

Mutate calls f(ctx, m).

type QuestionTranslationFunc

type QuestionTranslationFunc func(context.Context, *ent.QuestionTranslationMutation) (ent.Value, error)

The QuestionTranslationFunc type is an adapter to allow the use of ordinary function as QuestionTranslation mutator.

func (QuestionTranslationFunc) Mutate

Mutate calls f(ctx, m).

type ResponseFunc

type ResponseFunc func(context.Context, *ent.ResponseMutation) (ent.Value, error)

The ResponseFunc type is an adapter to allow the use of ordinary function as Response mutator.

func (ResponseFunc) Mutate

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

Mutate calls f(ctx, m).

type ResultFunc

type ResultFunc func(context.Context, *ent.ResultMutation) (ent.Value, error)

The ResultFunc type is an adapter to allow the use of ordinary function as Result mutator.

func (ResultFunc) Mutate

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

Mutate calls f(ctx, m).

type SampleFunc

type SampleFunc func(context.Context, *ent.SampleMutation) (ent.Value, error)

The SampleFunc type is an adapter to allow the use of ordinary function as Sample mutator.

func (SampleFunc) Mutate

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

Mutate calls f(ctx, m).

type ScaleFunc

type ScaleFunc func(context.Context, *ent.ScaleMutation) (ent.Value, error)

The ScaleFunc type is an adapter to allow the use of ordinary function as Scale mutator.

func (ScaleFunc) Mutate

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

Mutate calls f(ctx, m).

type ScaleItemFunc

type ScaleItemFunc func(context.Context, *ent.ScaleItemMutation) (ent.Value, error)

The ScaleItemFunc type is an adapter to allow the use of ordinary function as ScaleItem mutator.

func (ScaleItemFunc) Mutate

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

Mutate calls f(ctx, m).

type ScaleTranslationFunc

type ScaleTranslationFunc func(context.Context, *ent.ScaleTranslationMutation) (ent.Value, error)

The ScaleTranslationFunc type is an adapter to allow the use of ordinary function as ScaleTranslation mutator.

func (ScaleTranslationFunc) Mutate

Mutate calls f(ctx, m).

type TagFunc

type TagFunc func(context.Context, *ent.TagMutation) (ent.Value, error)

The TagFunc type is an adapter to allow the use of ordinary function as Tag mutator.

func (TagFunc) Mutate

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

Mutate calls f(ctx, m).

type TagTranslationFunc

type TagTranslationFunc func(context.Context, *ent.TagTranslationMutation) (ent.Value, error)

The TagTranslationFunc type is an adapter to allow the use of ordinary function as TagTranslation mutator.

func (TagTranslationFunc) Mutate

Mutate calls f(ctx, m).

type TakeFunc

type TakeFunc func(context.Context, *ent.TakeMutation) (ent.Value, error)

The TakeFunc type is an adapter to allow the use of ordinary function as Take mutator.

func (TakeFunc) Mutate

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

Mutate calls f(ctx, m).

type TestDisplayFunc

type TestDisplayFunc func(context.Context, *ent.TestDisplayMutation) (ent.Value, error)

The TestDisplayFunc type is an adapter to allow the use of ordinary function as TestDisplay mutator.

func (TestDisplayFunc) Mutate

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

Mutate calls f(ctx, m).

type TestFunc

type TestFunc func(context.Context, *ent.TestMutation) (ent.Value, error)

The TestFunc type is an adapter to allow the use of ordinary function as Test mutator.

func (TestFunc) Mutate

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

Mutate calls f(ctx, m).

type TestTranslationFunc

type TestTranslationFunc func(context.Context, *ent.TestTranslationMutation) (ent.Value, error)

The TestTranslationFunc type is an adapter to allow the use of ordinary function as TestTranslation mutator.

func (TestTranslationFunc) Mutate

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).

type UserSessionFunc

type UserSessionFunc func(context.Context, *ent.UserSessionMutation) (ent.Value, error)

The UserSessionFunc type is an adapter to allow the use of ordinary function as UserSession mutator.

func (UserSessionFunc) Mutate

func (f UserSessionFunc) 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